Language Codes in SEO (hreflang) — Multilingual SEO Guide
How to use hreflang tags with correct language codes for multilingual SEO, including implementation patterns and common pitfalls.
Detailed Explanation
hreflang and Language Codes for SEO
The hreflang attribute tells search engines which language and regional version of a page to show to users in different locales. Getting the language codes right is critical for international SEO.
hreflang Syntax
<link rel="alternate" hreflang="en" href="https://example.com/page" />
<link rel="alternate" hreflang="en-US" href="https://example.com/en-us/page" />
<link rel="alternate" hreflang="ja" href="https://example.com/ja/page" />
<link rel="alternate" hreflang="x-default" href="https://example.com/page" />
Rules for hreflang Values
- Use ISO 639-1 two-letter language codes
- Optionally add ISO 3166-1 alpha-2 country codes after a hyphen
- Language code is required; region code is optional
x-defaultdesignates the fallback page for unmatched languages- Every page listed in hreflang must link back to all others (bidirectional)
Common Patterns
Language only (recommended when content is not region-specific):
<link rel="alternate" hreflang="en" href="/en/page" />
<link rel="alternate" hreflang="ja" href="/ja/page" />
<link rel="alternate" hreflang="de" href="/de/page" />
Language + region (when content varies by country):
<link rel="alternate" hreflang="en-US" href="/en-us/page" />
<link rel="alternate" hreflang="en-GB" href="/en-gb/page" />
<link rel="alternate" hreflang="pt-BR" href="/pt-br/page" />
<link rel="alternate" hreflang="pt-PT" href="/pt-pt/page" />
Implementation Methods
- HTML
<link>tags in<head>(most common) - HTTP headers (useful for PDFs and non-HTML resources)
- XML sitemap (best for large sites with many language versions)
Sitemap Implementation
<url>
<loc>https://example.com/page</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/page" />
<xhtml:link rel="alternate" hreflang="ja" href="https://example.com/ja/page" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/page" />
</url>
Common Mistakes
- Using
en-ukinstead ofen-GB(UK is not a valid ISO 3166-1 code for the country; GB is) - Missing the
x-defaulttag - Non-reciprocal links (page A links to B, but B does not link back to A)
- Using ISO 639-2 three-letter codes (hreflang requires two-letter ISO 639-1)
- Pointing hreflang to non-canonical URLs
Use Case
Every multilingual website needs hreflang for proper international SEO. Without it, search engines may show the wrong language version to users, leading to high bounce rates and lost traffic. E-commerce sites, SaaS platforms, and media companies with international audiences rely on correct hreflang implementation.
Try It — Language Code Reference
Related Topics
Language Tags in HTML — The lang Attribute Guide
Web Development
BCP 47 Language Tags — The Web Standard for Locale Identifiers
Standards
Accept-Language Header — HTTP Content Negotiation
Web Development
ISO 639-1 Overview — Two-Letter Language Codes
Standards
Regional Language Variants — en-US vs en-GB and Beyond
Internationalization