Deutsch
hreflang & language tags

hreflang sitemap

Also known as: hreflang in XML sitemap

hreflang in an XML sitemap is one of three ways to tell Google about language and country versions of a page. Instead of the HTML head, the links sit in the sitemap as xhtml:link entries for each URL.

How does it work?

The sitemap needs the namespace xmlns:xhtml="http://www.w3.org/1999/xhtml". According to Google, each <url> element must contain a child <xhtml:link rel="alternate" hreflang="..."> for every alternate version, including the page itself. Each language version gets its own <url> block with the same set of links, so the versions confirm each other.

The method helps when the HTML head is hard to change or when the links are generated from central data. Errors become visible in the sitemap file or in testing tools rather than on the page. According to Google, the xhtml:link child elements do not count toward a sitemap’s URL limit, and using several methods at once brings no benefit.

hreflang cluster with four language versionsFour pages de-DE, de-AT, en and x-default all point to each other. Only between en and de-AT the return link is missing: en points to de-AT, but de-AT does not point to en. Google therefore ignores this pair.de-DEexample.com/de-de/de-ATexample.com/de-at/enexample.com/en/x-defaultexample.com/point to each other: validone-way only: pair is ignoredEvery page lists all four versions, including itself.
Four language versions of one page. Each lists all versions, including itself. de-AT does not list en, so Google ignores the one-way link from en to de-AT. Source: Google Search Central: Tell Google about localized versions of your page.

Example

XML
<url>
  <loc>https://example.com/en/page/</loc>
  <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/page/"/>
  <xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/seite/"/>
  <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/"/>
</url>

A second <url> block for https://example.com/de/seite/ holds the same three links.

Common mistakes

  • A version is missing or does not link back
  • The page does not list itself
  • Language and region codes in the wrong order, such as the region first

Sources

  1. Tell Google about localized versions of your page – Google Search Centraldevelopers.google.com
  2. hreflang sitemap – Weglot (secondary)weglot.com
  3. XML sitemap with hreflang tags – seoClarity (secondary)seoclarity.net

Last updated: