Agent Wranglers

Languages and regions Optional

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. Use either the sitemap or the HTML links as the main source, and keep them in sync.

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 url lists the same set of versions as the page's HTML.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/languages-and-regions/sitemap-hreflang.