I'm trying to pass a page through the W3C Validator. The validation fails on the sitemap, which I'm including like this:
<link rel="sitemap" type="application/xml" title="Sitemap" href="../sitemap.xml" />
The error I'm getting is:
Bad value sitemap for attribute rel on element link: Not an absolute IRI. The string sitemap is not a registered keyword or absolute URL.
I have been trying forever to fix it, but nothing I'm trying seems to work plus this is the recommended layout by Google and Html5 Boilerplate.
Is there anything wrong with my syntax? Seems correct, but why is it not passing?
The short answer is that you cannot.
HTML 5 defines the values that you are allowed to use in rel
and sitemap
is not one of the ones recognised by the validator.
The error message does say that you can register a new link type on a wiki, but sitemap is already there so you just have to wait for the validator developers to update the validator to reflect the new state of the wiki (assuming nobody deletes the entry).
(The basic problems here are that having the specification use a wiki page as a normative resource is nuts, that HTML 5 is still a draft, and that the HTML 5 validator is still considered experimental).
Dropping in from the future (June 2021).
The entry:
<link rel="sitemap" type="application/xml" title="Sitemap" href="/sitemap.xml">
is now accepted by the W3 HTML5 Validator
That is to say:
rel="sitemap"
is now a valid attribute + value.
Validating the following HTML file:
<!DOCTYPE html>
<html lang="en-gb">
<head>
<meta charset="utf-8">
<title>My Rel Sitemap Test</title>
<link rel="sitemap" type="application/xml" title="Sitemap" href="/sitemap.xml">
</head>
<body>
<h1>My Rel Sitemap Test</h1>
<p>This is my Rel Sitemap Test.</p>
<p>The document passes.</p>
<p>This document is valid HTML5 + ARIA + SVG 2 + MathML 3.0</p>
</body>
</html>
here: https://validator.w3.org/nu/
returns the response:
Document checking completed. No errors or warnings to show.
If you only need w3c validator to pass, perhaps you could detect its user agent and modify the output of your application so that it passes. I think of strict validation as more of a marketing benefit then anything when it comes to minor issues like this. If other developers use w3c validator to say your client's web site is full of errors, then that is annoying.
You can check if the HTTP_USER_AGENT contains "W3C_Validator" and remove the non-standard code.
In CFML, I wrote code like this to make my Google Authorship link still able to validate on w3c validator:
<cfif cgi.HTTP_USER_AGENT CONTAINS "W3C_Validator">data-</cfif>rel="publisher"
I just posted a question on the google forum if they could begin supporting data-rel or if they could confirm if google search does already support it. The structured data testing tool they provide doesn't parse data-rel when I tested it just now. http://www.google.com/webmasters/tools/richsnippets
Hopefully, someone will follow up: https://groups.google.com/a/googleproductforums.com/d/msg/webmasters/-/g0RDfpFwmqAJ
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With