If your website serves more than one country or language, you have probably seen this problem: a customer in London lands on your US page with dollar prices, or a Spanish speaker in Mexico sees your Spain page with the wrong shipping details. Search engines are good at detecting language, but they need help to understand which version of a page is meant for which audience.
That is the job of hreflang. In this guide you will learn what hreflang tags do (and what they do not), the exact syntax Google supports, the three ways to implement them, how x-default works, and how to audit and fix the errors that break most international setups.
Hreflang is one part of a wider technical foundation; our technical SEO guide covers the rest.
Key Takeaways
- Hreflang tells Google which language or regional versions of a page exist, so it can show the right one to each user.
- Values use ISO 639-1 language codes, optionally followed by ISO 3166-1 Alpha 2 region codes (for example
en-GB). - Every version must list itself and all other versions, and links must be reciprocal.
- Use
x-defaultfor a fallback page such as a language selector. - Implement via HTML, HTTP headers or XML sitemaps; Google treats them as equivalent.
What Are Hreflang Tags?
Hreflang is an attribute of the <link rel="alternate"> element that tells search engines about alternate versions of a page for different languages or regions. For example, you might have English pages for the US, the UK and Australia, plus a Spanish version for Mexico.
It is important to understand what hreflang is not:
- It is not a ranking boost; it helps the right version appear for the right user.
- It is not a language detector. Google determines a page's language algorithmically.
- It is not a redirect. Users are not moved automatically; search results simply show the best match.
“Google doesn't use hreflang or the HTML lang attribute to detect the language of a page.”
— Google Search Central, Tell Google about localized versions of your page
When You Need Hreflang
- The same content is translated into multiple languages.
- The same language is used for different regions with differences in currency, pricing, spelling or legal details (US vs UK English, Spain vs Mexico Spanish).
- Only part of a page is translated, such as the navigation, while the main content stays the same.
Region variants in the same language are a classic source of duplicate content. Hreflang helps Google understand the pages are alternates, but genuine localisation (prices, contact details, examples) is what makes each version useful.
Hreflang Syntax
Each value starts with an ISO 639-1 language code. You can optionally add a hyphen and an ISO 3166-1 Alpha 2 region code. You cannot specify a region alone.
| Value | Meaning | Valid? |
|---|---|---|
en | English speakers anywhere | Yes |
en-GB | English speakers in the United Kingdom | Yes |
en-UK | “UK” is not the ISO region code for the United Kingdom | No |
es-419 | Spanish for Latin America (UN M.49 region code) | No for Google; use country codes |
de-AT | German speakers in Austria | Yes |
GB | Region on its own | No |
zh-Hant | Chinese in Traditional script | Yes (script subtag) |
x-default | Fallback when no other version matches | Yes |
Google's documentation states that only ISO 639-1 language codes and ISO 3166-1 Alpha 2 region codes are supported, and that alternate URLs must be fully qualified, including https://.
Three Ways to Implement Hreflang
Google's localized versions documentation says the three methods are equivalent from Google's perspective. Pick the one that best suits your platform and use only one, to avoid conflicting signals.
| Method | Best for | Pros | Cons |
|---|---|---|---|
HTML <link> tags in <head> | Small to mid-sized sites | Easy to see and debug | Adds code to every page; heavy with many locales |
HTTP Link header | PDFs and other non-HTML files | Works without HTML | Needs server configuration; harder to audit |
| XML sitemap | Large sites with many locales | Centralised, no page bloat | Less visible; must stay in sync with URLs |
HTML example
This block goes in the <head> of every version listed, unchanged:
<link rel="alternate" hreflang="en-US" href="https://www.example.com/us/pricing/" />
<link rel="alternate" hreflang="en-GB" href="https://www.example.com/uk/pricing/" />
<link rel="alternate" hreflang="es-MX" href="https://www.example.com/mx/precios/" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/pricing/" />
HTTP header example (for a PDF)
Link: <https://www.example.com/us/guide.pdf>; rel="alternate"; hreflang="en-US",
<https://www.example.com/uk/guide.pdf>; rel="alternate"; hreflang="en-GB"
XML sitemap example
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://www.example.com/us/pricing/</loc>
<xhtml:link rel="alternate" hreflang="en-US" href="https://www.example.com/us/pricing/"/>
<xhtml:link rel="alternate" hreflang="en-GB" href="https://www.example.com/uk/pricing/"/>
</url>
<url>
<loc>https://www.example.com/uk/pricing/</loc>
<xhtml:link rel="alternate" hreflang="en-US" href="https://www.example.com/us/pricing/"/>
<xhtml:link rel="alternate" hreflang="en-GB" href="https://www.example.com/uk/pricing/"/>
</url>
</urlset>
Notice that each <url> entry repeats the full set of alternates. For general sitemap rules, see our XML sitemap guide.
The Two Rules That Break Most Setups
1. Self-reference and return links
Each language version must list itself as well as all other versions. If page A points to page B but B does not point back to A, Google ignores the annotation. This is why hreflang is best generated from one central mapping rather than edited page by page.
2. Hreflang and canonicals must agree
Each localised page should have a self-referencing canonical. If your UK page canonicalises to the US page, you are telling Google the UK page is a duplicate, which contradicts the hreflang annotation. Hreflang URLs should also point only to canonical, indexable pages that return 200. Our canonical tag explainer covers the basics.
What x-default Does
The reserved x-default value tells Google which page to show when no other language or region matches the user's browser settings. It is typically a language selector page or your main international homepage. It is optional but recommended for any site with a global audience.
How to Implement Hreflang: Step by Step
- List your target markets as language or language-region pairs (for example
en-US,en-GB,de). - Choose a URL structure: country-code domains, subdomains or subfolders. Subfolders on one domain are usually easiest to manage.
- Build a mapping table linking each page to its equivalent in every locale.
- Choose one implementation method (HTML, header or sitemap) and generate tags from the mapping automatically.
- Add x-default pointing at your fallback page.
- Check canonicals are self-referencing on each locale.
- Audit with a crawler that validates return links and codes, and monitor performance by country in Search Console.
Common Hreflang Mistakes
- Missing return links, so annotations are ignored.
- Invalid codes such as
en-UKoren-EU, or region-only values. - Relative URLs such as
/uk/instead of fully qualified URLs. - Pointing to redirected, 404 or noindexed URLs. Every target should be a live canonical page.
- Canonicalising all locales to one version, which cancels out the hreflang setup.
- Forcing automatic IP-based redirects. Google's multi-regional guidance recommends against automatically redirecting users based on perceived language; let users switch versions with clear links instead, and avoid hiding versions from Googlebot, which mostly crawls from the US.
- Translating only the template. If the main content is identical, the versions offer little distinct value.
Related Guides
- JavaScript SEO: How to Make JS Sites Search-Friendly
- Crawl Budget: What It Is and When It Matters
- Mobile SEO: How to Optimize for Mobile-First Indexing
Frequently Asked Questions
Is hreflang a ranking factor?
No. Hreflang does not boost rankings. It helps Google show the most appropriate language or regional version of a page to each user, which can improve click-through and conversions.
Does Google use hreflang to detect a page's language?
No. Google says it does not use hreflang or the HTML lang attribute to detect language; it uses its own algorithms. Hreflang tells Google which alternate versions exist.
Do I need hreflang if I only have one language?
Usually not. Hreflang is for sites with multiple language or regional versions of the same content. A single-language site targeting one market does not need it.
Is 'en-uk' a valid hreflang value?
No. The ISO 3166-1 Alpha 2 code for the United Kingdom is GB, so the correct value is en-GB. Hreflang values are case-insensitive, but the codes themselves must be valid.
Which hreflang method is best?
Google treats HTML tags, HTTP headers and sitemaps as equivalent. HTML tags suit small sites, sitemaps suit large sites, and HTTP headers are for non-HTML files such as PDFs.
Does Bing support hreflang?
Bing has historically relied more on signals such as the content-language meta tag and the HTML lang attribute. If Bing traffic matters, set those correctly alongside hreflang.
Conclusion
Hreflang is fussy but logical. Use valid ISO codes, fully qualified URLs, a complete and reciprocal set of alternates on every version, self-referencing canonicals and an x-default fallback. Generate it from one central mapping and audit it after every release. Pair it with genuinely localised content, and international visitors will land on the page that was built for them. Include hreflang checks in every technical SEO audit, and keep an eye on crawl efficiency as locale counts grow.
Expanding into new markets? Our enterprise SEO team plans and implements international SEO, from URL structure to hreflang at scale. Get a free quote to discuss your rollout.




