Hreflang Tag
Hreflang tags are HTML attributes that tell search engines which language or regional version of a page to show to users.
Key facts
- Hreflang is implemented with
rel="alternate" hreflang="x"link annotations. - It indicates the language of a page and can optionally specify a geographic target.
- Each URL in a language cluster should point to the other variants, including a self-reference.
- Use valid language and locale codes (e.g., en, en-US, fr-CA) for accurate targeting.
- Hreflang is a signal, not a directive, so it helps disambiguate but does not guarantee rankings.
- An
x-defaulthreflang value indicates a fallback page for unspecified language or region.
Also called
hreflang attribute, alternate hreflang, language targeting tag
Use it for
Language and region targeting of web pages
Applies to
Google and other major search engines
How Hreflang Tags Work
Hreflang tags are a key component of International SEO. They use a simple annotation: rel="alternate" hreflang="x" in the HTML <head>, XML sitemap, or HTTP header. When you have the same content in multiple languages or regions, you tell search engines: 'This page is the English version, that one is the French version.'
The search engine then shows the most appropriate variant to users based on their language and location settings. For example, a user in Canada with French language settings might see your fr-CA page instead of the en-US one.
Crucially, hreflang works on a cluster model. Each page in the cluster must link to every other variant, including itself. If you have English, French, and German pages, the English page must reference the French and German pages, and vice versa. A missing reciprocal link can break the cluster.
- If you have an English page and a French page, each must link to the other.
- For three variants (e.g., en, fr, de), each page links to both other variants.
- Always include a self-referencing link to confirm the page's own variant.
Implementing Hreflang
You can implement hreflang in three ways. The choice depends on your site architecture and technical setup, and is part of multilingual seo planning.
Method 1: HTML <head> — Add a <link rel="alternate" hreflang="x" href="..."> tag for each variant, including the current page. This is straightforward for small sites, and can be automated via CMS for dynamic pages.
Method 2: XML sitemap — Include <xhtml:link rel="alternate" hreflang="x" href="..."> for each URL entry. This scales better for large sites with many language versions and is Google's preferred method for extensive international sites.
Method 3: HTTP headers — For non-HTML resources like PDFs, use the Link HTTP header with hreflang annotations. This method is rarely used but essential for downloadable files.
- Always include a self-referencing hreflang tag for each page.
- Use an
x-defaultfallback for users whose language or region is not covered. - Keep hreflang clusters consistent across all pages — no orphaned variants.
Valid Language and Region Codes
Hreflang requires valid language codes from ISO 639-1 and optional region codes from ISO 3166-1 Alpha 2. The format is language-region, such as en-US for English in the United States or fr-CA for French in Canada. Ensuring correct codes is similar to heading tags seo best practices for consistency.
If you only specify a language (e.g., en), the tag applies globally to that language. Never use invalid codes like 'en-uk' (correct: en-GB) or 'fr-fr' (correct: fr-FR). Incorrect codes are ignored by search engines, so always double-check against ISO standards.
Common mistakes include using 'en-uk' instead of 'en-GB', or 'pt' instead of 'pt-BR' for Brazilian Portuguese. Also note that language codes should be lowercase, region codes uppercase, e.g., 'en-US' not 'en-us'.
Common Hreflang Mistakes
Even experienced SEOs make mistakes with hreflang, which can undermine cctld seo strategies. The most common errors break the cluster and reduce targeting accuracy.
Mistake 1: Using hreflang for pages that are not equivalent versions of the same content. Consequence: Search engines become confused, potentially indexing the wrong page or ignoring the cluster.
Mistake 2: Missing reciprocal links between language or regional variants. Consequence: The cluster is incomplete, and search engines may not apply the targeting correctly.
Mistake 3: Mixing up language codes and country codes, or using invalid locale formats. Consequence: Invalid codes are ignored, so targeting fails silently.
Mistake 4: Forgetting to include self-referencing hreflang annotations or an x-default fallback when needed. Consequence: The page's own language variant is not confirmed, and users without a specific match may see a less relevant page.
Hreflang and Canonical Tags
Hreflang and canonical tags work together but serve different purposes. Canonical tags tell search engines which URL is the preferred version for indexing, while hreflang tells them which version to show in different regional contexts. This alignment with global seo priorities is crucial.
You can have a canonical tag pointing to one URL and hreflang tags pointing to multiple regional variants. This is common for sites with a single language but multiple regions (e.g., en-US, en-GB).
However, if you have completely different content for each region, use separate URLs with no cross-canonicalization. The key is to ensure consistency: the hreflang cluster should match the canonicalization logic. For example, if your canonical is en-US, the hreflang set should include en-US as a variant. Also, ensure your url structure supports clean differentiation.
If canonical and hreflang conflict, search engines may ignore both signals. Always verify that the canonical URL is also included in the hreflang cluster to avoid confusion.
When to Use x-default
The x-default hreflang value serves as a fallback for users whose language or region does not match any of the other variants. It is commonly used on a homepage or landing page that is language-neutral or uses browser detection to redirect, and can be managed via Google Tag Manager if dynamic injection is needed.
For example, if your site has English, French, and German pages, but you also have a generic page that auto-redirects based on user location, you can tag that page with x-default. This tells search engines: 'If no specific language or region matches, show this page.'
Using x-default is not mandatory, but it helps prevent users from seeing a random variant when no match exists. It also improves the user experience for international visitors, similar to Title Tag optimisation for click-through.
| Code | Language | Region |
|---|---|---|
| en | English | Global |
| en-US | English | United States |
| fr-CA | French | Canada |
| de | German | Global |
| x-default | Fallback | No specific target |
Common mistakes
- Using hreflang for pages that are not equivalent versions of the same content. Search engines become confused, potentially indexing the wrong page or ignoring the cluster.
- Missing reciprocal links between language or regional variants. The cluster is incomplete, and search engines may not apply the targeting correctly.
- Mixing up language codes and country codes, or using invalid locale formats. Invalid codes are ignored, so targeting fails silently.
- Forgetting to include self-referencing hreflang annotations or an `x-default` fallback when needed. The page's own language variant is not confirmed, and users without a specific match may see a less relevant page.
Questions
What is the hreflang tag?
Hreflang is an HTML attribute that tells search engines which language or regional version of a page to show. It helps serve the right content to users based on their language and location. It is implemented using rel="alternate" hreflang="x".
How do I implement hreflang tags?
You can implement hreflang in three ways: in the HTML <head> of each page, in an XML sitemap, or via HTTP headers. Each method requires you to list all language and region variants, including a self-reference and an optional x-default fallback.
Does hreflang affect SEO rankings?
No, hreflang is a signal for targeting, not a ranking factor. It helps search engines show the right page to the right user, which can improve click-through rates and user experience, but it does not directly boost rankings.
What is x-default in hreflang?
x-default is a special hreflang value that indicates a fallback page for users whose language or region does not match any other variant. It is commonly used on a generic homepage or landing page that uses browser detection to redirect.
See also
- Canonical TagA canonical tag is an HTML element that tells search engines which URL is the master version wh…
- Canonical ErrorA canonical error happens when search engines cannot tell which URL is the preferred version of…
- Canonical URLA canonical URL is the preferred web address you want search engines to treat as the main versi…
- H1 Tag SEOAn H1 tag is the HTML element used as the main heading on a webpage, identifying its primary to…
- SEO Friendly URLAn SEO Friendly URL is a concise, human-readable web address that accurately reflects the page'…
Sources
- Google Search Central: Localized versions developers.google.com
- Google Search Central: Locale-adaptive pages developers.google.com
- Ahrefs: Hreflang Tags Guide ahrefs.com
- Moz: Hreflang Tag moz.com
Outbound links are unpaid and nofollow. If one has gone stale, tell me.