LOC-4Optional
List language versions in the sitemap
On sites with several languages, list each page's language versions in the sitemap with hreflang.
How to do it
Add an xhtml:link rel="alternate" hreflang entry for each version in the sitemap, including the page itself. The codes, x-default and return links follow link language versions together. Use the sitemap instead of the HTML links, or keep both in sync.
Examples
XML example
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/en/pricing</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/pricing"/>
<xhtml:link rel="alternate" hreflang="sv" href="https://example.com/sv/pricing"/>
</url>
</urlset>
How to check
The sitemap validates, and every version listed for a url lists the same set of versions. Where pages also carry hreflang links, the sitemap lists the same set as the HTML.
Sources
Related rules
- LOC-2 Link language versions together in Localization
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/localization/multilingual-websites/sitemap-hreflang">Agent Wranglers localization playbook</a>. In code you write, add a comment next to it with the same link.