Hreflang is an HTML attribute that tells search engines about language and regional versions of a page. It helps Google serve the correct URL to users based on their language or location. Format: hreflang='en-US' (English for US). Hreflang must be bidirectional - all versions must reference each other and themselves.
Hreflang is an HTML attribute that tells search engines about language and regional versions of a page. It helps Google serve the correct URL to users based on their language or location. Format: hreflang=“en-US” (English for US). Hreflang must be bidirectional - all versions must reference each other and themselves.
What is Hreflang?
Hreflang is an attribute that indicates the language and optionally the geographic target of a webpage. It’s used when you have multiple versions of content for different languages or regions.
Hreflang purposes:
- Show correct language version in search results
- Prevent duplicate content issues between versions
- Target specific geographic markets
- Improve user experience for international visitors
When to Use Hreflang
Use Hreflang When
- Same content in multiple languages
- Same language, different regions (en-US vs en-GB)
- Translated pages with equivalent content
- Regional variations with different pricing/products
Don’t Need Hreflang When
- Single language website
- No regional targeting needed
- Automatically translated content (consider noindex)
- Different content that happens to be in different languages
Hreflang Syntax
Language Only
Use ISO 639-1 language codes.
<link rel="alternate" hreflang="en" href="https://example.com/page/">
<link rel="alternate" hreflang="es" href="https://example.com/es/page/">
<link rel="alternate" hreflang="de" href="https://example.com/de/page/">
Language + Region
Combine language code with ISO 3166-1 Alpha-2 country code.
<link rel="alternate" hreflang="en-US" href="https://example.com/us/page/">
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/page/">
<link rel="alternate" hreflang="en-AU" href="https://example.com/au/page/">
x-default
Specifies fallback for unmatched languages/regions.
<link rel="alternate" hreflang="x-default" href="https://example.com/page/">
Complete Hreflang Example
For a page with English, Spanish, and German versions:
<head>
<!-- Self-reference -->
<link rel="alternate" hreflang="en" href="https://example.com/page/">
<!-- Other versions -->
<link rel="alternate" hreflang="es" href="https://example.com/es/pagina/">
<link rel="alternate" hreflang="de" href="https://example.com/de/seite/">
<!-- Fallback -->
<link rel="alternate" hreflang="x-default" href="https://example.com/page/">
</head>
Important: Each version must include ALL hreflang tags, including self-reference.
Implementation Methods
HTML Link Tags
<link rel="alternate" hreflang="en" href="https://example.com/page/">
Pros: Easy to implement, visible in source Cons: Adds to page size, must update each page
HTTP Headers
For non-HTML files (PDFs).
Link: <https://example.com/page/>; rel="alternate"; hreflang="en",
<https://example.com/es/page/>; rel="alternate"; hreflang="es"
XML Sitemap
<url>
<loc>https://example.com/page/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/page/"/>
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/pagina/"/>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/seite/"/>
</url>
Pros: Centralized management, easier updates Cons: Not visible on page, may have crawl delay
Common Hreflang Codes
Language Codes (ISO 639-1)
| Code | Language |
|---|---|
| en | English |
| es | Spanish |
| de | German |
| fr | French |
| zh | Chinese |
| ja | Japanese |
| pt | Portuguese |
| ar | Arabic |
| ms | Malay |
Country Codes (ISO 3166-1)
| Code | Country |
|---|---|
| US | United States |
| GB | United Kingdom |
| DE | Germany |
| FR | France |
| ES | Spain |
| AU | Australia |
| MY | Malaysia |
| SG | Singapore |
Combined Examples
| Hreflang | Target |
|---|---|
| en-US | English for US |
| en-GB | English for UK |
| es-ES | Spanish for Spain |
| es-MX | Spanish for Mexico |
| pt-BR | Portuguese for Brazil |
| pt-PT | Portuguese for Portugal |
| zh-CN | Chinese for China (Simplified) |
| zh-TW | Chinese for Taiwan (Traditional) |
Hreflang Best Practices
Bidirectional Requirement
All pages must reference each other.
Correct:
Page A (en) references: A (en), B (es), C (de)
Page B (es) references: A (en), B (es), C (de)
Page C (de) references: A (en), B (es), C (de)
Incorrect:
Page A (en) references: B (es), C (de) // Missing self-reference
Page B (es) references: A (en) // Missing C
Use Absolute URLs
<!-- Correct -->
<link rel="alternate" hreflang="en" href="https://example.com/page/">
<!-- Incorrect -->
<link rel="alternate" hreflang="en" href="/page/">
Match Canonical URLs
Hreflang URLs should match canonical URLs.
<link rel="canonical" href="https://example.com/page/">
<link rel="alternate" hreflang="en" href="https://example.com/page/">
Return 200 Status
All hreflang URLs must return 200 (not redirects or errors).
Include Self-Reference
Always include the current page in hreflang.
URL Structures for International Sites
Subdirectories (Recommended)
example.com/en/
example.com/es/
example.com/de/
Pros: Easy to implement, shared domain authority Cons: No separate geo-targeting in Search Console
Subdomains
en.example.com
es.example.com
de.example.com
Pros: Can geo-target in Search Console Cons: Separate domain authority, more setup
ccTLDs
example.com (US)
example.co.uk (UK)
example.de (Germany)
Pros: Strong geo-signal, local trust Cons: Separate domains to manage, divided authority
Troubleshooting Hreflang
Common Errors
| Error | Cause | Solution |
|---|---|---|
| Missing return links | One-directional references | Add reciprocal tags |
| Wrong codes | Invalid language/country | Use correct ISO codes |
| Broken links | URLs return errors | Fix or remove URLs |
| Conflicting signals | Canonical conflicts | Align canonical and hreflang |
Validation Tools
- Google Search Console (International Targeting)
- Hreflang Tags Testing Tool
- Ahrefs/Semrush site audit
- Screaming Frog
Search Console Reports
Check:
- International Targeting section
- Coverage report for hreflang errors
- URL Inspection for specific pages
Hreflang Checklist
Implementation
- All language versions identified
- Correct ISO codes used
- x-default included
- Absolute URLs used
- Self-reference on each page
Validation
- Bidirectional links verified
- All URLs return 200
- Canonical URLs match
- No conflicting signals
- Search Console checked
Maintenance
- New pages get hreflang
- Removed pages cleaned up
- URL changes updated
- Regular audits scheduled
Conclusion
Hreflang is essential for multilingual and international websites. It ensures users see the correct language version in search results and prevents duplicate content issues between regional versions.
Implement hreflang on all alternate versions, always include self-reference, and ensure bidirectional linking. Use x-default as a fallback for unmatched languages. Validate regularly with Search Console and site audit tools.
Combine hreflang with proper canonicalization and international SEO strategy for effective global search visibility.