XML sitemap
<xhtml:link>
An hreflang alternate for a URL, declared in the XHTML namespace — the only correct way to express language variants in a sitemap.
Each <xhtml:link rel="alternate" hreflang="…" href="…"/> names one language or regional variant of the enclosing <url>. The set has to be complete and reciprocal: every variant must list every other, itself included, or search engines discard the group.
It lives in the XHTML namespace, which the sitemap must declare on its root. Dropping that declaration during a refactor is how a whole hreflang set disappears silently — the elements remain in the file and mean nothing.
- Format
- XML sitemap
- Namespace
- XHTML
- Parent
- <url>
- How many
- Any number per <url>, one per variant including the URL itself.
What it contains
Nothing — this element holds a value rather than other elements. Its content is text, and the constraints below are what that text has to be.
Attributes
relrequiredAlways "alternate" in a sitemap.hreflangrequiredA BCP 47 language tag, or x-default.hrefrequiredThe absolute URL of that variant.
Cardinality and constraints
Any number per <url>, one per variant including the URL itself.
- Requires xmlns:xhtml="http://www.w3.org/1999/xhtml" on the root element.
- rel="alternate", plus hreflang and href attributes. It is always an empty element.
- The set must be reciprocal and self-referential: each variant lists all of them, itself included.
- hreflang values are language, or language-region: en, en-GB, x-default.
What our validator does
We do not check hreflang sets — the namespace check will flag a prefix that is used but never declared, which is the failure that actually happens.
We do not catch this one
The German variant is declared here but the English one is not, so the set is not reciprocal and search engines will drop it. Our sitemap checks do not model hreflang groups, and neither document below produces an issue.Broken and fixed
Both documents below are well-formed XML — that is the point of this corpus — and both are run through the validator on every test run. The verdicts here are what it returned, not what we expect it to.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/</loc>
<lastmod>2026-08-10</lastmod>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/"/>
</url>
</urlset><?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/</loc>
<lastmod>2026-08-10</lastmod>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/"/>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/"/>
</url>
</urlset>Where it reaches
- NamespacesXHTMLThe namespace this element belongs to, and which the root has to declare.
- Datatypesxs:languageThe type behind an hreflang value, and what makes one well-formed.
- ToolsXML validatorReports a prefix used but never declared, which is how a hreflang set vanishes.
Related elements
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.