"Hreflang Sitemap: Multilingual SEO Done Right"
Hreflang tells Google which version of your page to show in each language and region. Learn how to implement it in your sitemap and avoid the most common mistakes.
If your site serves users in multiple languages or regions, hreflang is one of the most important signals you can provide to Google — and also one of the most misunderstood. Get it wrong and you end up with the Spanish version of your homepage ranking in France, or your British English page serving users in Australia who expect something different.
This guide explains what hreflang is, how to implement it in your sitemap, and the mistakes that quietly break multilingual SEO.
What is hreflang?
Hreflang is a signal that tells Google which language or regional version of a page to show each user. In a sitemap, you add <xhtml:link rel="alternate" hreflang="..."> entries inside each <url>, listing every language variant — including the page itself and an x-default fallback. Every page in a group must reference every other page, or Google ignores the signal.
Hreflang is an HTML attribute (and sitemap extension) that tells Google the relationship between different language or regional versions of the same page. When a user searches in German, Google uses hreflang signals to decide whether to show them your /de/ page instead of your default English page.
Without hreflang, Google guesses. It may get it right for obvious language mismatches, but for regional variations — US English versus UK English, Brazilian Portuguese versus European Portuguese — guessing produces inconsistent results.
Hreflang can be implemented in three ways:
- HTML
<link rel="alternate">tags in the<head>of each page - HTTP headers (for non-HTML files like PDFs)
- XML sitemaps
The sitemap approach is often the most practical for large sites because it centralizes all the hreflang declarations in one place rather than requiring changes to every page template. It builds on the standard XML sitemap format — if you are new to sitemaps, start with what an XML sitemap is before layering hreflang on top. Hreflang is one of several namespace extensions to the base format; image sitemaps work the same way, adding image tags inside each <url> entry.
The <xhtml:link> tag in sitemaps
Sitemap hreflang uses the xhtml: namespace extension. Each <url> entry needs to list all its language variants, including itself. Here is what a two-language setup looks like:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/about</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/about"/>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/ueber-uns"/>
<xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/a-propos"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/about"/>
</url>
<url>
<loc>https://example.com/de/ueber-uns</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/about"/>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/ueber-uns"/>
<xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/a-propos"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/about"/>
</url>
<url>
<loc>https://example.com/fr/a-propos</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/about"/>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/ueber-uns"/>
<xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/a-propos"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/about"/>
</url>
</urlset>
A few things to notice:
- Every
<url>entry lists all its variants, including itself - The
hreflangvalue uses BCP 47 language tags (en,de,fr,pt-BR,en-GB) - The
x-defaulttag tells Google which version to show when no specific language matches
Language tags and regional variants
BCP 47 language codes follow a simple pattern:
- Language only:
en,de,fr,es,zh - Language + region:
en-GB,en-AU,pt-BR,zh-TW
Use the language-only code when you have one version for all speakers of a language. Add the region code when you have meaningfully different content or pricing for different countries.
Do not create regional variants just for the sake of it. If your US English and UK English pages are identical, having separate hreflang entries for each adds complexity without helping users or Google. Create regional variants when there are genuine differences: currency, spelling, legal copy, product availability, or pricing.
For Chinese, the distinction matters: zh-Hans (simplified, mainland China) and zh-Hant (traditional, Taiwan and Hong Kong) are meaningfully different.
The x-default tag
The x-default hreflang value tells Google which page to serve when none of the language-specific pages match the user's language. This is typically your default language — usually English — but it could also be a language-selection landing page.
Common patterns:
- Single default language: point
x-defaultat your English page - Explicit language chooser: point
x-defaultat a/choose-languagepage - Region-gated pricing: point
x-defaultat an international pricing page
Omitting x-default is not a critical error — Google will still use your hreflang data — but it is a missed opportunity to control the fallback experience.
The most common hreflang mistakes
Non-reciprocal links. Every page in a hreflang group must reference every other page. If your English page lists the German variant but the German page does not list the English variant back, Google ignores the signal from that pair entirely. This is the single most common cause of hreflang not working.
Missing x-default. Forgetting the x-default tag means Google has no fallback instruction. For sites with many language variants, this often results in the wrong version appearing in searches where no specific match exists.
Using wrong language codes. en-uk is not a valid BCP 47 tag — it should be en-GB. Using lowercase region codes or incorrect ISO codes means Google cannot interpret the tag. Always use ISO 639-1 for the language and ISO 3166-1 Alpha-2 (uppercase) for the region.
Including pages that return 4xx errors. If a page in your hreflang group is returning a 404 or 403, that breaks the reciprocal relationship. Google will ignore or demote the entire cluster. This happens when pages are deleted but the sitemap is not updated — a common reason your sitemap falls out of date.
Mixing sitemap and HTML hreflang declarations inconsistently. If your HTML <head> has hreflang tags and your sitemap has different hreflang tags for the same pages, the signals conflict. Pick one method and use it consistently across your entire site.
Large sitemap files with incomplete hreflang data. For sites with thousands of pages and multiple language variants, sitemap files can become very large. If you use sitemap index files to split them up, make sure the hreflang clusters are not accidentally split across files in a way that breaks reciprocity.
Structuring a multilingual sitemap for larger sites
For a site with many pages and several languages, a sitemap index file with one sitemap per language is a clean approach:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemaps/en.xml</loc>
</sitemap>
<sitemap>
<loc>https://example.com/sitemaps/de.xml</loc>
</sitemap>
<sitemap>
<loc>https://example.com/sitemaps/fr.xml</loc>
</sitemap>
</sitemapindex>
Each language sitemap then contains the full hreflang cluster for all pages in that language. The advantage: each file stays manageable in size, and you can see at a glance if a language's sitemap is out of sync with the others.
The disadvantage: each page's hreflang data is split across multiple files. This is fine — Google processes all sitemaps submitted to Search Console together — but it requires your generation process to build the cross-references correctly.
Verifying hreflang with Search Console
Google Search Console's International Targeting report shows hreflang errors at scale. After submitting your sitemap, watch for:
- Return tag errors — the non-reciprocal link problem described above
- Unknown language — invalid BCP 47 codes
- No return tag — a page references a variant that does not reference it back
These errors are reported per URL, so for large sites you can see which pages are affected and fix them systematically.
Hreflang is not glamorous SEO work, but for any site serving users in multiple languages it is essential infrastructure. The most important rule is also the simplest: every page in a group must reference every other page. If you take nothing else from this article, internalize that one constraint — it is responsible for the majority of hreflang failures in the wild.
FAQ
What is hreflang in a sitemap?
Hreflang in a sitemap is a set of <xhtml:link rel="alternate"> tags added inside each <url> entry. Each tag names a language or region variant of that page and its URL. Together they tell Google which version to serve to which users. The sitemap method keeps all hreflang declarations in one file instead of editing every page template.
Do I need x-default in hreflang?
The x-default tag is not strictly required, but it is strongly recommended. It tells Google which page to show when none of your language versions match the user's language. Without it, Google has no fallback instruction and may pick the wrong version for users outside your defined languages. Point x-default at your default language or a language-selection page.
Why is my hreflang not working?
The most common cause is non-reciprocal links: every page in a hreflang group must reference every other page, including itself. If page A lists page B but page B does not list page A back, Google ignores that pair. Other causes include invalid language codes, missing x-default, and pages that return 404 errors inside the group.
Can I use hreflang and image tags in the same sitemap?
Yes. Both hreflang and image data are namespace extensions to the standard sitemap format, so you can declare both namespaces on the <urlset> tag and add both kinds of tags inside a <url> entry. Keep the file within the 50,000-URL and 50MB limits, and split into a sitemap index if you exceed them.
Generate your sitemap with Indexly — crawl any site and keep a permanent, current sitemap URL for Google.
Anas Shikh Al Srojieh · Founder, indexly
Writing about SEO, sitemaps, and how to get every page indexed by Google.
Enjoyed this post?
Get our next one delivered to your inbox — no spam, ever.
Ready to get your site fully indexed?
Get started free