• Resolved lamayas

    (@lamayas)


    Hello,

    I recently tested a couple of my sites with the W3C Markup Validation Service and got a lot of notices about Trailing slash on void elements:

    https://tinyurl.com/29myudyu

    At first I thought it might be a theme issue but I tested different sites with different themes and got the same notice. All of the meta properties found in the head of the site appear flagged with this notice, and since the HTML code can’t be edited directly, I’m not sure how to fix them.

    I have not found much info about this online, only got results about trailing slashes creating duplicated URLs but that’s not what’s happening here.

    I’d appreaciate any help about this or a push in the right direction.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @lamayas,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    We are well aware of the meta tags structure for the web as described here.
    https://www.w3schools.com/tags/tag_meta.asp

    However, this is more than the meta tags since we and everyone else are following the guidelines by OpenGraph and Facebook OpenGraph guideline:
    https://ogp.me/#metadata
    https://developers.facebook.com/docs/sharing/webmasters/#markup-example

    Hence, you can continue using the current meta tags you have. But if you still wish to change them by removing the trailing slash, let us know here and we’ll try to assist you with a filter/hook.

    Looking forward to helping you.

    Thread Starter lamayas

    (@lamayas)

    Please do! I’d like to try that.

    Thanks!

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @lamayas,

    All the metatags added by the Rank Math plugin are correctly written. The notices you get in the W3C validator are only info, and it also states that it has no effect and interacts badly with unquoted attribute values. We never use unquoted attribute values in the metatags, so this shouldn’t be a problem. You can ignore those info messages.

    However, as per your request, we tried to build a filter/hook to remove the trailing slash, but we noticed that this might create complexity upon application.

    Hence, the easiest way would be to edit the plugin’s core file, even though that’s not the recommended way.

    Please head over to /wp-content/plugins/seo-by-rank-math/includes/frontend/class-head.php:

    Edit line 200 and replace it with the following one:
    echo '<meta name="robots" content="', esc_attr( $robotsstr ), '">', "\n";

    Edit line 217 and replace it with the following one:
    echo '<link rel="canonical" href="' . esc_url( $canonical, null, 'other' ) . '" >' . "\n";

    After that, head over to /wp-content/plugins/seo-by-rank-math/includes/opengraph/class-opengraph.php:

    Edit line 182 and replace it with the following one:
    printf( '<meta %1$s="%2$s "content="%3$s">' . "\n", $tag, esc_attr( $property ), $escaped_value );

    Please stay advised that all these changes will revert once you update the plugin to the latest version.

    If you don’t want to use the OpenGraph tags generated by Rank Math, you simply remove and add them from any other sources:
    https://rankmath.com/kb/filters-hooks-api-developer/#remove-opengraph-tags

    Hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘W3C Validation Errors’ is closed to new replies.