Skip to main content
Skip to main content
Technical SEO
Last reviewed: November 1, 2026

Hreflang Tags Guide: HTML, HTTP Headers, Sitemaps & x-default

How to implement hreflang annotations for multilingual and multi-regional sites: ISO language and region codes, bidirectional return links, and canonicals.

Quick answer

Hreflang annotations (rel="alternate" hreflang="lang-region") tell Google which language or regional URL variant to show searchers in different locales. Every translated or regional page in a cluster must reference itself and every other variant in the cluster using valid ISO 639-1 language codes and optional ISO 3166-1 alpha-2 country codes, paired with self-referencing canonicals on distinct localized pages (or a preferred regional canonical when same-language regional variants are near-identical duplicates).

Perfect SEO Tools Team
11 min read

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).

  1. Language code (Required): Must be a valid two-letter ISO 639-1 code (for example, en for English, es for Spanish, de for German, ja for Japanese).
  2. 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" or hreflang="MX" is invalid; you must prefix it with the language (en-GB, es-MX).
  3. Script code (When needed): For languages written in multiple scripts, use ISO 15924 script codes such as zh-Hans (Simplified Chinese) and zh-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 CodeWhy Google Ignores ItCorrect ISO Code
en-UKUK is not an assigned ISO 3166-1 alpha-2 code; the United Kingdom is GB.en-GB
en-EU or es-LAEU (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 krJP and KR are country codes, not ISO 639-1 language codes.ja-JP (or ja) and ko-KR (or ko)
chs / chtNon-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:

  1. Bidirectional reciprocity (return links): If Page A (en-US) links to Page B (de-DE) via hreflang="de-DE", Page B must link back to Page A via hreflang="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.
  2. Self-referencing inclusion: Every page in the cluster must include a hreflang link pointing to itself alongside its links to every other sibling variant.
  3. Fully qualified absolute indexable URLs: Every href in a hreflang set must be an absolute URL (https://example.com/de/tools/, never /de/tools/) that returns 200 OK and 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.

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/):

<!-- 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/" />

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"

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, point x-default to that selector URL.
  • If you do not have a dedicated country selector page, point x-default to your primary international fallback locale (for example, https://example.com/en-us/pricing/ — yes, the same URL can appear twice in the set: once as hreflang="en-US" and once as hreflang="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:

  1. 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 an hreflang cluster 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/" />
  2. Near-identical same-language regional variants (Google's preferred-canonical exception): As noted in Google's canonicalization documentation, if your en-US and en-GB URLs 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 in rel="canonical" while still keeping the bidirectional hreflang annotations 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#

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.

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.

Related Articles

Technical SEO

XML Sitemap Best Practices: Limits, lastmod & Sitemap Indexes

How to build and maintain clean XML sitemaps under the Sitemaps 0.9 protocol: size limits, lastmod rules, canonical purity, and sitemap index files.

10 min read
Technical SEO

Canonical Tag Guide: How rel=canonical Works

Use rel=canonical to consolidate duplicate URLs: correct markup, HTTP header canonicals, signal strength, and common implementation mistakes.

8 min read
Technical SEO

Google Search Console Crawl Stats Report: Diagnose Crawl Budget

How to audit the Google Search Console Crawl Stats report to spot 5xx host failures, faceted parameter traps, and discovery vs refresh bottlenecks.

10 min read