When you have multiple versions of the same page targeting different languages or regions, explicitly telling Google about these variations helps it serve the most appropriate page to users.
Why Use hreflang and Alternate Annotations? #
- Google may find alternate versions on its own but explicitly indicating them is best practice.
- Useful when you have:
- Same content in multiple languages
- Small regional variations in a single language (e.g., US English, UK English)
- Partial translations like translated templates with untranslated user content
- Same content in multiple languages
- Localized pages are duplicates only if the main content is identical and untranslated.
3 Methods to Indicate Alternate Language/Region Versions #
| Method | When to Use | Notes |
| HTML Tags | For typical web pages where you can edit <head> | Most common, simple to maintain |
| HTTP Headers | For non-HTML files like PDFs | Useful for downloadable documents |
| XML Sitemap | For large sites or when you want to centralize hreflang | Works well for big sites, needs XML editing |
You can choose any one method or combine, but managing one well is easier.
General Guidelines for hreflang Tags #
- Each language version must list itself and all other variants.
- URLs must be fully qualified, including https:// or http://.
- Alternate URLs can be on different domains.
- For languages spoken in multiple regions, add a generic language-only version for unspecified locales (e.g., en for all English speakers).
- Tags must be bidirectional (page A points to B and B points back to A), otherwise ignored.
- Use x-default for fallback pages (language selectors or default homepage).
Example: HTML hreflang Tags in <head>
Suppose you have pages for:
- English (generic)
- English UK (en-gb)
- English US (en-us)
- German (de)
- Default landing page (x-default)
<head>
<link rel=”alternate” hreflang=”en” href=”https://en.example.com/page.html” />
<link rel=”alternate” hreflang=”en-gb” href=”https://en-gb.example.com/page.html” />
<link rel=”alternate” hreflang=”en-us” href=”https://en-us.example.com/page.html” />
<link rel=”alternate” hreflang=”de” href=”https://de.example.com/page.html” />
<link rel=”alternate” hreflang=”x-default” href=”https://www.example.com/” />
</head>
Example: HTTP Header for PDFs #
Link: <https://example.com/file-en.pdf>; rel=”alternate”; hreflang=”en”,
<https://example.com/file-de.pdf>; rel=”alternate”; hreflang=”de”,
<https://example.com/file-fr.pdf>; rel=”alternate”; hreflang=”fr”
Example: XML Sitemap hreflang Entries #
<urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9″
xmlns:xhtml=”http://www.w3.org/1999/xhtml”>
<url>
<loc>https://example.com/en/page.html</loc>
<xhtml:link rel=”alternate” hreflang=”en” href=”https://example.com/en/page.html”/>
<xhtml:link rel=”alternate” hreflang=”de” href=”https://example.com/de/page.html”/>
<xhtml:link rel=”alternate” hreflang=”x-default” href=”https://example.com/”/>
</url>
<url>
<loc>https://example.com/de/page.html</loc>
<xhtml:link rel=”alternate” hreflang=”en” href=”https://example.com/en/page.html”/>
<xhtml:link rel=”alternate” hreflang=”de” href=”https://example.com/de/page.html”/>
<xhtml:link rel=”alternate” hreflang=”x-default” href=”https://example.com/”/>
</url>
</urlset>
Supported hreflang Codes #
- Format: language or language-region (ISO 639-1 + optional ISO 3166-1 Alpha 2)
- Examples:
- en (English, generic)
- en-gb (English UK)
- de (German)
- de-ch (German Swiss)
- zh-Hant (Chinese Traditional)
- zh-Hans-US (Chinese Simplified for US)
- en (English, generic)
Don’t use only country code (e.g., be is Belarusian language, not Belgium).
Use the x-default for Fallback Pages #
- The x-default hreflang value is for a fallback page (e.g., language selector or homepage).
- It tells Google what to show when no language matches user preferences.
Example:
<link rel=”alternate” hreflang=”x-default” href=”https://example.com/country-selector” />
Common Mistakes to Avoid #
- Missing bidirectional hreflang links
- Incorrect or unsupported language and region codes
- Using region code alone without language (e.g., uk instead of en-gb)
- Not using fully-qualified URLs (must include https://)
- Forgetting to include the current page in hreflang annotations
Tools to Validate hreflang #
- Aleyda Solis’s hreflang tag generator
- Merkle’s hreflang tag testing tool