---
title: "hreflang in XML sitemaps"
category: i18n
status: optional
url: https://webspecification.com/spec/i18n/sitemap-hreflang/
updated: "2026-05-29T18:54:03.000Z"
sources:
- title: "Google Search Central — Tell Google about localized versions"
url: "https://developers.google.com/search/docs/specialty/international/localized-versions"
publisher: "Google Search Central"
- title: "sitemaps.org — XML sitemap protocol"
url: "https://www.sitemaps.org/protocol.html"
publisher: "sitemaps.org"
- title: "BCP 47 — Tags for Identifying Languages"
url: "https://www.rfc-editor.org/info/bcp47"
publisher: "IETF"
source_repo: undefined
licence: CC-BY-4.0
---
# hreflang in XML sitemaps
> Declare language and regional alternates inside the XML sitemap with xhtml:link instead of in the HTML head. Easier to maintain at scale and keeps localisation metadata separate from content.
## What it is
The sitemap form of [hreflang](/spec/i18n/hreflang/). Instead of declaring language and regional alternates with `` in every HTML head, you list them once per URL inside the XML sitemap using the `` element. The namespace `xmlns:xhtml="http://www.w3.org/1999/xhtml"` is declared on the root ``. The signal sent to search engines is identical to the inline form — only the delivery mechanism changes.
```xml
https://example.com/en/pagehttps://example.com/de/seitehttps://example.com/fr/page
```
## Why it matters
On a large multilingual site, declaring hreflang inline becomes painful. A cluster of ten locales means ten `` elements in every page's head, every locale, every template — eleven with `x-default`. Adding an eleventh locale touches every template and every cached page. Moving the declaration to the sitemap keeps page HTML clean, centralises localisation metadata in one machine-generated file, and lets you add or remove a locale by regenerating one document.
The signal is equivalent. Google, Bing and Yandex all read `` entries from the sitemap as authoritative alternates.
## How to implement
- **Pick one delivery method per site.** Use either inline [hreflang](/spec/i18n/hreflang/) in the HTML head, the HTTP `Link` header, or sitemap `` — not several at once on the same URLs. Mixed signals get ignored or produce conflicts.
- **Declare the namespace.** Add `xmlns:xhtml="http://www.w3.org/1999/xhtml"` on the root ``.
- **Group all alternates inside each ``.** Every `` entry lists every alternate URL in the group, including itself. The bidirectional rule still applies: if A lists B, B must list A.
- **Self-reference always.** Each URL must include a `` pointing at itself with its own `hreflang`. Omitting it invalidates the entire cluster.
- **Add `x-default`.** Point it at the language selector or the default-region landing page.
- **Use BCP 47 tags.** Language (`en`, `de`), or language plus region (`en-GB`, `pt-BR`). Never a country code on its own.
- **Reach for the sitemap when** you have many locales, many pages, or generate alternates from the same source that already generates the sitemap. Reach for inline `` when you don't ship an XML sitemap, or when alternates differ from how the sitemap is built.
## Common mistakes
- Forgetting the `xmlns:xhtml` namespace declaration — the entries parse but search engines ignore them.
- Listing only the "other" languages and skipping the self-reference.
- Shipping both inline `` and sitemap `` for the same URLs, with different sets.
- Pointing alternates at non-canonical URLs, redirects, or 404s.
- Splitting a language cluster across multiple sitemap files — keep all alternates of a URL inside the same `` entry.
## Verification
- Fetch the sitemap and confirm the `xhtml` namespace is declared on ``.
- Pick one URL and confirm every alternate listed there reciprocally lists it back.
- Use Search Console's International Targeting report (or equivalent) to confirm clusters are detected without "no return tags" errors.