The hreflang attribute (rel="alternate" hreflang="x") tells search engines which language and region a webpage targets. It helps Google serve the correct localized version of your content to users based on their browser settings and location. Use it to stop traffic leaks to wrong-language versions and to clarify relationships between similar pages for different regions.
What is hreflang?
Hreflang is an HTML meta element defined in RFC 8288 that specifies the language and optional geographic restrictions for a document. Google introduced support for the attribute in [December 2011] (Moz) to help webmasters manage multilingual content. Google's John Mueller describes hreflang as [one of the most complex aspects of SEO] (Ahrefs) because implementation errors compound quickly.
The attribute acts as a signal, not a directive. Search engines may still consider other factors like relevance and authority when choosing which version to display. While Google and [Yandex support hreflang] (Ahrefs), [Bing relies on the content-language HTML attribute instead] (Moz).
Why hreflang matters
- Prevents traffic to wrong-language versions. When searchers land on a page they cannot read, they bounce. Hreflang directs French speakers to your French content and German speakers to your German content.
- Clarifies duplicate content relationships. If you have near-identical English pages for the US and UK that differ only in currency or spelling, hreflang identifies these as intentional regional variants rather than duplicates to consolidate.
- Enables ranking signal sharing. Pages in an hreflang cluster can share ranking signals in certain scenarios. As Google's Gary Illyes notes, the strongest page in a cluster may determine the ranking position, but search engines swap in the most relevant regional version for the specific user.
- Improves user engagement. Users spend more time on content in their native language, which can improve dwell time and reduce bounce rates.
- Supported by major search engines. Google and Yandex use hreflang. Bing uses it as a weak signal but primarily relies on other methods.
How hreflang works
Implement hreflang using one of three methods: HTML tags in the <head>, HTTP headers, or XML sitemaps. Use only one method per page.
HTML tags
Add <link rel="alternate" hreflang="lang-code" href="url" /> to the <head> section. Each page must list itself and all alternate versions.
HTTP headers
Return a Link header with your server's response. Use this for non-HTML files like PDFs.
Example: Link: <https://example.com/file.pdf>; rel="alternate"; hreflang="en"
XML sitemaps
Use <xhtml:link rel="alternate" hreflang="lang-code" href="url"/> within your sitemap <url> entries. This keeps markup out of your HTML.
Technical requirements
- Bidirectional linking: Every hreflang relationship must point both ways. If page A lists page B as an alternate, page B must list page A. These connected pages form an hreflang cluster.
- Self-referential tags: Include a tag on each page that points to itself along with its alternates.
- Fully-qualified URLs: Use absolute URLs including the protocol (https://), not relative paths.
- ISO codes: Use ISO 639-1 for language (e.g., en) and ISO 3166-1 Alpha 2 for optional region codes (e.g., us).
- x-default: Use this reserved value for fallback pages when no language matches, typically on language selector pages.
Best practices
- Audit before launch. A study of 374,756 domains found that [67% of hreflang implementations had issues] (Ahrefs). Validate your markup with third-party tools before publishing.
- Verify region codes. The United Kingdom uses
gb, notuk. Switzerland usesch. Always check ISO 3166-1 Alpha 2 codes. - Include generic language tags. When you have regional variants (like
en-usanden-gb), add a genericentag to capture traffic from other English-speaking regions. - Point x-default to a global page. Use x-default on language selector pages or pages that redirect based on user location. This captures traffic from unmatched languages.
- Keep hreflang clusters tight. Link new language versions bidirectionally to your dominant language (typically your original site language) first. For example, if your site started in French, link new Spanish and Mexican pages back to the French versions initially.
- Use canonical URLs. Ensure hreflang tags point only to canonical URLs, not to pages with canonical tags pointing elsewhere.
Common mistakes
Mistake: Missing return links. If page X links to page Y via hreflang, but page Y does not link back, Google ignores the tags. Fix: Add bidirectional hreflang annotations on every page in the cluster.
Mistake: Incorrect ISO codes. Using uk instead of gb for the United Kingdom, or be (Belarusian language) for Belgium.
Fix: Verify codes against the ISO 639-1 and ISO 3166-1 Alpha 2 standards. Use en-gb for UK English, de-be for German in Belgium.
Mistake: Missing self-references. A page references its alternates but omits itself from the set. Fix: Include a self-referential hreflang tag on every page. While Google states these are optional, they remain best practice.
Mistake: One URL mapped to multiple languages. Assigning the same URL to both hreflang="en" and hreflang="fr".
Fix: Ensure each URL serves one language and has one hreflang value.
Mistake: Hreflang pointing to non-canonical URLs. The hreflang target has a canonical tag pointing to a different URL. Fix: Point hreflang only to canonical URLs. If you need to consolidate signals, use canonical tags within the cluster carefully.
Mistake: Using relative URLs. Implementing hreflang with /page instead of https://example.com/page.
Fix: Use fully-qualified absolute URLs.
Mistake: Hreflang to broken or blocked pages. Linking to 404s or pages blocked by robots.txt. Fix: Verify all URLs in hreflang clusters return 200 status codes and are indexable.
Examples
Regional currency variations
You sell products in the US and UK. The pages are identical except for currency (USD vs GBP).
On https://example.com/us/:
<link rel="alternate" hreflang="en-us" href="https://example.com/us/" />
<link rel="alternate" hreflang="en-gb" href="https://example.com/uk/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
The UK version must contain the same set of tags, pointing back to the US version.
Language script variations Targeting Chinese speakers with Traditional vs Simplified scripts:
<link rel="alternate" hreflang="zh-Hant" href="https://example.com/zh-tw/" />
<link rel="alternate" hreflang="zh-Hans" href="https://example.com/zh-cn/" />
Non-HTML files A PDF available in English and German via HTTP header:
Link: <https://example.com/file.pdf>; rel="alternate"; hreflang="en", <https://de.example.com/file.pdf>; rel="alternate"; hreflang="de"
Hreflang vs canonicalization
| Hreflang | Canonicalization | |
|---|---|---|
| Purpose | Identify language and regional variants | Identify the preferred URL among duplicates |
| Use case | Same content in different languages or regions | Near-identical content in the same language |
| Key attribute | rel="alternate" hreflang="x" |
rel="canonical" |
| Effect | Swaps ranking URL to match user language | Consolidates ranking signals to one URL |
Rule of thumb: Use hreflang to manage international variations. Use canonical tags to consolidate duplicate pages within the same language. Never point an hreflang tag to a non-canonical URL.
FAQ
What is hreflang? Hreflang is an HTML attribute that tells search engines which language and optionally which region a webpage targets. It helps serve the correct localized version to users.
Do I need hreflang for similar English pages in the US and UK? Yes. If you have separate URLs for American and British English that differ only by spelling or currency, hreflang prevents Google from treating them as duplicate content and helps users find the relevant version.
How does hreflang differ from the HTML lang attribute?
Hreflang signals to search engines. The HTML lang attribute (<html lang="en">) signals to browsers and assistive technologies. Bing uses the HTML lang attribute as a primary signal, while Google uses hreflang. Keep both consistent.
What is x-default? X-default is a reserved hreflang value for pages that do not target a specific language or region. Use it on language selector pages or global homepages to capture traffic from unmatched user settings.
Can I implement hreflang in my sitemap instead of HTML?
Yes. XML sitemaps support hreflang via <xhtml:link> elements. This method keeps your HTML clean and is often easier to manage for large sites than editing individual page headers.
Why are my hreflang tags not working? Common causes include missing return links (bidirectional linking), incorrect ISO codes, pointing to non-canonical URLs, or linking to pages that return 404 errors. Use validation tools to check your implementation.
Does Bing support hreflang?
Bing treats hreflang as a weak signal and primarily relies on the HTML content-language meta tag, links, and visitor data to determine language.
Can I automate hreflang implementation? Yes. For small to medium sites, use Google Sheets templates or scripts to generate hreflang sitemaps. For enterprise sites, implement logic in your content management system to auto-generate tags based on page language and region settings.