When a website publishes pages for multiple languages (en, de, es) or
multiple countries speaking the same language (en-US, en-GB, en-AU with
USD, GBP, and AUD pricing), search engines need an explicit map connecting each
localized URL to its siblings. As documented in
Google Search Central's Localized Versions guide,
the hreflang attribute swaps the right regional or language URL into search
results for a user's locale and helps search engines understand that near-identical
regional variants (such as US and UK English product pages) are intentional
localized alternates rather than duplicate content.
How ISO 639-1 language and ISO 3166-1 alpha-2 region codes work#
Every hreflang value (except x-default) follows
RFC 5646 (BCP 47) syntax:
language or language-region (or language-script).
- Language code (Required): Must be a valid two-letter
ISO 639-1 code (for example,
enfor English,esfor Spanish,defor German,jafor Japanese). - Region code (Optional): Must be a valid two-letter
ISO 3166-1 alpha-2 country code (for example,
US,GB,CA,MX,DE). A region code cannot stand alone:hreflang="GB"orhreflang="MX"is invalid; you must prefix it with the language (en-GB,es-MX). - Script code (When needed): For languages written in multiple scripts, use
ISO 15924 script codes such as
zh-Hans(Simplified Chinese) andzh-Hant(Traditional Chinese), or combine script and region (zh-Hant-HK,zh-Hant-TW).
The four most common ISO code typos that break hreflang#
| Broken Code | Why Google Ignores It | Correct ISO Code |
|---|---|---|
en-UK | UK is not an assigned ISO 3166-1 alpha-2 code; the United Kingdom is GB. | en-GB |
en-EU or es-LA | EU (European Union) and LA (used mistakenly for Latin America; LA is Laos!) are not valid supranational region codes in hreflang. | en or es (language-only catch-all) |
jp or kr | JP and KR are country codes, not ISO 639-1 language codes. | ja-JP (or ja) and ko-KR (or ko) |
chs / cht | Non-standard legacy shorthand for Chinese scripts. | zh-Hans and zh-Hant |
The three non-negotiable rules of hreflang clusters#
Before choosing an implementation method, every hreflang cluster must obey
three structural invariants:
- Bidirectional reciprocity (return links): If Page A (
en-US) links to Page B (de-DE) viahreflang="de-DE", Page B must link back to Page A viahreflang="en-US". If the return link is missing, Google ignores the unconfirmed annotation so third-party sites cannot arbitrarily claim to be an official regional alternate of your pages. - Self-referencing inclusion: Every page in the cluster must include a
hreflanglink pointing to itself alongside its links to every other sibling variant. - Fully qualified absolute indexable URLs: Every
hrefin ahreflangset must be an absolute URL (https://example.com/de/tools/, never/de/tools/) that returns200 OKand is consistent with your canonicalization strategy (self-referencing canonicals for genuinely distinct translated or localized pages).
The three ways to implement hreflang#
Google supports three equivalent places to declare hreflang clusters. Pick
one method per page template rather than duplicating annotations across HTML
and sitemaps, which often drift out of sync.
Method 1: HTML <link> elements in <head>#
Best for small-to-medium sites with a handful of locales. Each localized page
must output its own self-referencing canonical (href matching the current
page's URL), followed by the identical set of <link rel="alternate" hreflang="...">
annotations inside the <head> of every URL in the cluster (en-US,
en-GB, de-DE, and the global selector). For example, on the en-US page
(https://example.com/en-us/pricing/):
Try These Related SEO Tools
<!-- Self-referencing canonical: vary this href per page so each locale canonicalizes to itself -->
<link rel="canonical" href="https://example.com/en-us/pricing/" />
<!-- Shared hreflang cluster: place this identical alternate block on every locale URL -->
<link rel="alternate" hreflang="en-US" href="https://example.com/en-us/pricing/" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/pricing/" />
<link rel="alternate" hreflang="de-DE" href="https://example.com/de-de/pricing/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing/" />
Method 2: HTTP Link response headers#
Used for non-HTML files such as localized PDF whitepapers or downloadable guides
that have no HTML <head>:
Link: <https://example.com/en-us/guide.pdf>; rel="alternate"; hreflang="en-US",
<https://example.com/de-de/guide.pdf>; rel="alternate"; hreflang="de-DE",
<https://example.com/en-us/guide.pdf>; rel="alternate"; hreflang="x-default"
Method 3: XML Sitemaps (xhtml:link)#
For large sites with 10 to 40 locales, injecting 40 <link rel="alternate">
lines into every HTML document adds several kilobytes of markup to every page
response and requires redeploying pages whenever a new country launches. Placing
hreflang inside your XML sitemap keeps HTML payloads lean and centralizes the
cluster map:
<?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/en-us/pricing/</loc>
<xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-us/pricing/" />
<xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/pricing/" />
<xhtml:link rel="alternate" hreflang="de-DE" href="https://example.com/de-de/pricing/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/pricing/" />
</url>
<url>
<loc>https://example.com/en-gb/pricing/</loc>
<xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-us/pricing/" />
<xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/pricing/" />
<xhtml:link rel="alternate" hreflang="de-DE" href="https://example.com/de-de/pricing/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/pricing/" />
</url>
<url>
<loc>https://example.com/de-de/pricing/</loc>
<xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-us/pricing/" />
<xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/pricing/" />
<xhtml:link rel="alternate" hreflang="de-DE" href="https://example.com/de-de/pricing/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/pricing/" />
</url>
<url>
<loc>https://example.com/pricing/</loc>
<xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-us/pricing/" />
<xhtml:link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/pricing/" />
<xhtml:link rel="alternate" hreflang="de-DE" href="https://example.com/de-de/pricing/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/pricing/" />
</url>
</urlset>
See our XML sitemap best practices guide and our sitemap index generator for how to split large multi-locale sitemaps cleanly under the 50MB / 50,000-URL limit.
How x-default works#
The hreflang="x-default" value tells search engines which page to show when no
other language or region in the cluster matches the user's browser and location
settings.
- If your root URL (
https://example.com/pricing/) presents a country/language selector or dynamically adapts without a forced redirect, pointx-defaultto that selector URL. - If you do not have a dedicated country selector page, point
x-defaultto your primary international fallback locale (for example,https://example.com/en-us/pricing/— yes, the same URL can appear twice in the set: once ashreflang="en-US"and once ashreflang="x-default").
Canonical tags and hreflang: distinct translations vs same-language regional duplicates#
How rel="canonical" interacts with hreflang depends on whether your regional
pages contain genuinely distinct localized content or near-identical same-language
copy:
- Translated or substantially localized pages (Use self-referencing canonicals):
Never set the
rel="canonical"tag on your German (/de-de/) or localized UK (/en-gb/with UK-specific pricing, inventory, and copy) page to point back to the US (/en-us/) URL. A cross-language canonical tells Google not to index the translated page at all. Every genuinely distinct localized page in anhreflangcluster should carry a self-referencing canonical tag:https://example.com/en-us/pricing/-><link rel="canonical" href="https://example.com/en-us/pricing/" />https://example.com/en-gb/pricing/-><link rel="canonical" href="https://example.com/en-gb/pricing/" />https://example.com/de-de/pricing/-><link rel="canonical" href="https://example.com/de-de/pricing/" />
- Near-identical same-language regional variants (Google's preferred-canonical exception):
As noted in Google's canonicalization documentation,
if your
en-USanden-GBURLs serve essentially identical English content (differing only by minor regional boilerplate), Google may fold them together as duplicates. For near-identical same-language regional duplicates, you can either localize the pages substantially so each earns a self-canonical, or specify your preferred regional URL inrel="canonical"while still keeping the bidirectionalhreflangannotations so Google can swap the regional URL into search results for matching locales.
Review our canonical tag guide and verify your tags with the canonical tag manager and SEO and meta tags analyzer.
Why auto-redirecting by IP or Accept-Language blocks Googlebot#
Many international sites configure edge middleware to inspect the visitor's IP
country or Accept-Language header and automatically 302 redirect visitors to
a country subfolder.
As Google warns in
Managing Multi-Regional and Multilingual Sites,
Googlebot crawls primarily from IP addresses in the United States (without
sending localized Accept-Language headers on standard discovery crawls). If
your server 302 redirects every US IP request from /de-de/ or /en-gb/ back
to /en-us/, Googlebot can never fetch, render, or index your German or UK pages!
Instead of forced IP redirects, serve the requested URL with 200 OK and display
a non-blocking banner offering to switch to the visitor's preferred locale. Add
this check to your technical SEO audit workflow.
Frequently asked questions#
Does hreflang consolidate link equity across regional pages?#
No. Google has stated that hreflang swaps the localized URL into search
results for matching users, enabling sibling pages to share ranking display in
their target region, but it does not merge backlink signals the way a 301
redirect or rel="canonical" tag does. Maintain clear internal country/language
switcher links so users and crawlers can navigate between locales.
Should I use both a generic language code (en) and regional codes (en-US, en-GB)?#
Yes, when you serve specific regional pages (en-US with USD and en-GB with
GBP) and also want one of those pages (or a generic /en/ page) to serve English
speakers in Canada, Australia, or India, include hreflang="en" alongside
hreflang="en-US" and hreflang="en-GB".
What happens if one language version returns a 404 or is marked noindex?#
If any URL referenced in an hreflang cluster returns 404, redirects (301/302),
or carries a noindex directive, the bidirectional return link from that page
fails. Remove unpublished or retired regional URLs from your hreflang sets
immediately.
Sources#
Don't Miss Our SEO Updates
Get the latest SEO tools and strategies delivered to your inbox.
No spam, unsubscribe anytime. We respect your privacy.
Related SEO Paths
About the Author
The Perfect SEO Tools team consists of experienced SEO professionals, digital marketers, and technical experts dedicated to helping businesses improve their search engine visibility and organic traffic.