Hreflang sitemap

On this page 7

A hreflang sitemap is an XML sitemap that declares language and regional alternates for each URL by adding xhtml:link elements with rel="alternate" and a hreflang value. In international SEO it is one of the three supported ways to implement hreflang, alongside HTML link elements in the page head and HTTP headers.

Moving annotations into the sitemap keeps page templates clean and makes large multilingual and multiregional websites easier to manage, because all relationships live in files that can be generated, validated and versioned centrally.

How hreflang annotations work inside a sitemap

Each url entry in a hreflang sitemap lists every language or regional version of the same content, including a reference to itself. The sitemap must declare the xhtml namespace, and each alternate is written as xhtml:link with the attributes rel, hreflang and href.

The annotations form a hreflang cluster: a set of equivalent pages that all point to one another. Because every page in the cluster appears as its own url entry with the full list of alternates, the return tag requirement is satisfied automatically when the file is generated correctly.

The table below summarizes the elements and attributes that a valid entry contains.

Element or attributeRoleExample value
locCanonical URL of the page described by the entryPath such as /de-at/preise/
xhtml:linkDeclares one alternate versionOne element per language or region
relDefines the relationship typealternate
hreflangLanguage code, optionally with region codede-AT, en, x-default
hrefAbsolute URL of the alternate pageFull address of /en-gb/pricing/
Namespace declarationEnables the xhtml prefix in the fileThe W3C XHTML namespace URI
Building blocks of a hreflang sitemap entry

Language and region codes in a hreflang sitemap

Hreflang values use ISO 639-1 language codes, optionally followed by an ISO 3166-1 Alpha 2 region code, as in en-US or pt-BR. A region code alone is invalid, so us or uk without a language will be ignored, and en-UK is a common error because the correct region code for the United Kingdom is GB.

The special value x-default marks the fallback page for users whose language or location matches no listed version. It typically points to a language selector or a global English page and should appear in every entry of the cluster.

ValueValidMeaning or problem
enYesEnglish for all regions
en-GBYesEnglish for the United Kingdom
es-419No for GoogleUN M.49 region codes are not supported
en-UKNoUK is not an ISO 3166-1 code
zh-Hant-TWYesTraditional Chinese script for Taiwan
x-defaultYesFallback for unmatched users
Valid and invalid hreflang values

Sitemap method compared with other hreflang implementations

The sitemap method is functionally equivalent to HTML and HTTP header annotations for Google, so the choice depends on scale, technical control and maintenance effort. Mixing methods is allowed but increases the risk of conflicting signals, so most teams pick one method per site.

MethodBest suited forMain drawback
XML sitemapLarge sites with many language versionsChanges become visible only after recrawl of the sitemap
HTML link elementsSmall and medium sites with editable templatesAdds many lines to every page head
HTTP headersPDFs and other non-HTML filesHard to audit without server access
Comparison of hreflang implementation methods

On a site with 20 language versions, HTML annotations add 21 link lines to every page, which inflates page weight and complicates template releases. In a sitemap, the same data sits in a separate, machine-generated file that developers and SEO specialists can audit without touching page code.

Bing and several regional engines treat hreflang differently. Bing has historically relied more on the Content-Language meta tag or header, while Yandex supports hreflang in sitemaps, so a multi-engine strategy should not assume that one method covers every search engine.

Building and maintaining a hreflang sitemap at scale

Reliable hreflang sitemaps are generated from a single source of truth, typically a database table that maps each content item to its localized URLs. Manual editing breaks down quickly because one missing alternate invalidates part of the cluster.

  • List only canonical, indexable URLs that return status 200; redirected or noindexed pages create errors.
  • Respect the sitemap limits of 50,000 URLs and 50 MB uncompressed per file, and use a sitemap index for larger sets.
  • Remember that each alternate counts toward file size, so files with many languages reach the size limit before the URL limit.
  • Submit the files in Google Search Console and reference them in robots.txt so crawlers discover them.
  • Regenerate on publish and unpublish so new translations and removed pages are reflected immediately.

Alternate URLs may sit on different domains or subdomains, for example country-code domains, provided the site owner has verified each property. This makes the sitemap method particularly practical for international URL structures that span several ccTLDs.

Common errors and how to fix them

Most hreflang sitemap problems come from inconsistency between the sitemap and the live pages. Search engines read the annotations as hints, so conflicting canonicals, redirects or missing return references cause them to ignore parts of a cluster.

SymptomLikely causeFix
Missing return links reportedAlternate page lacks its own entryGenerate an entry for every member of the cluster
Wrong country version ranksInvalid region code or missing x-defaultCorrect codes and add x-default to each entry
Annotations ignoredAlternate URL is canonicalized elsewherePoint hreflang only to self-canonical URLs
Sitemap fetch errorsMissing namespace or file over size limitDeclare the namespace and split the file
Stale alternatesStatic file not updated after changesAutomate generation in the publishing workflow
Typical hreflang sitemap errors

A practical audit combines a crawler that parses sitemap hreflang, such as Screaming Frog, with spot checks of the international targeting signals in search results. The goal is a cluster in which every URL is canonical, reachable and reciprocal.

In simple terms

A hreflang sitemap is a list for search engines that says which pages are translations or regional versions of each other. Instead of writing this information on every page, the website keeps it in one file.

Think of it as a table of contents in several languages. When someone in Austria searches, the search engine can check the list and show the Austrian German page instead of the English or Swiss one.

A practical example

A software company runs its website in 14 language and country versions, from en-US and en-GB to de-DE, de-AT and ja-JP. Its marketing pages are built in a headless content system, and adding 15 link lines to every page head slowed releases and caused frequent template errors.

The development team moves all annotations into generated hreflang sitemaps, one file per section, each listing every localized URL with its alternates and an x-default pointing to a language selector. The files are rebuilt automatically whenever an editor publishes or removes a translation.

Within two months, Search Console reports far fewer hreflang errors, and users in Austria and the United Kingdom land more often on their own regional pages instead of the German or American versions.