What is hreflang?
Hreflang is an HTML attribute that tells search engines which language and region a page targets.
What is Hreflang?
Hreflang is an HTML attribute (formally rel="alternate" hreflang="x") introduced by Google in December 2011 to indicate the language and optional regional targeting of a webpage. It helps search engines serve the correct localized version of a page to users based on their language preferences and geographic location. The attribute accepts values formatted as ISO 639-1 language codes (e.g., en, fr) optionally combined with ISO 3166-1 Alpha-2 country codes (e.g., en-US, fr-CA). Every hreflang implementation must include a self-referencing tag and an x-default fallback for users who don't match any specified language-region pair. Without proper hreflang annotations, Google may display the wrong localized page in search results or flag duplicate content issues across regional domains. We've shipped hreflang across 50+ multilingual projects — it's one of the most misconfigured SEO signals we encounter in audits.
How it works
Hreflang annotations can be placed in three locations: HTML <head> link elements, HTTP headers, or XML sitemaps. The HTML approach is most common:
<link rel="alternate" hreflang="en-US" href="https://example.com/en-us/page" />
<link rel="alternate" hreflang="es-MX" href="https://example.com/es-mx/page" />
<link rel="alternate" hreflang="x-default" href="https://example.com/page" />
For non-HTML resources (PDFs, for instance), use the HTTP Link header:
Link: <https://example.com/es-mx/doc.pdf>; rel="alternate"; hreflang="es-MX"
The sitemap method scales best for large sites. Inside a <url> entry in your sitemap XML, you add <xhtml:link> elements:
<url>
<loc>https://example.com/en-us/page</loc>
<xhtml:link rel="alternate" hreflang="en-US" href="https://example.com/en-us/page" />
<xhtml:link rel="alternate" hreflang="es-MX" href="https://example.com/es-mx/page" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/page" />
</url>
Critical rules: annotations must be bidirectional (if page A references page B, page B must reference page A), every set must include a self-referencing entry, and all referenced URLs must return a 200 status. Broken return links are the single most common hreflang error we see — Google Search Console reports these under the "International Targeting" section. Yandex also recognizes hreflang, but Bing relies on the content-language meta tag instead.
When to use it
Hreflang is essential whenever you have multiple pages targeting different languages or regional audiences with substantially similar content.
Use hreflang when:
- You operate ccTLDs (e.g.,
.de,.fr) or subdirectories (/en/,/es/) for different locales - You have region-specific pages with different pricing, currency, or legal content (e.g.,
en-USvsen-GB) - You translate or localize blog posts and want each version to rank in the correct regional SERP
- You have an
x-defaultlanding page that auto-detects language and want to prevent it from cannibalizing localized pages
Skip hreflang when:
- You only publish in one language with no regional variants
- Your "translations" are machine-generated thin pages with no unique value — fix content quality first
- You're only targeting Bing — use
content-languageinstead
Our preferred stack for Next.js i18n projects is next-intl combined with programmatic sitemap generation (via next-sitemap) that auto-injects hreflang annotations at build time.
Hreflang vs alternatives
| Signal | Supported by | Placement | Best for |
|---|---|---|---|
hreflang attribute |
Google, Yandex | HTML head, HTTP header, XML sitemap | Language + region targeting |
content-language meta tag |
Bing | HTML head | Language signal for Bing |
Accept-Language server-side redirect |
All crawlers (risky) | Server config | Auto-redirecting users |
| Canonical URL | Google, Bing, Yandex | HTML head | Deduplicating same-language pages |
| Google Search Console International Targeting | GSC dashboard | Country-level targeting for ccTLDs |
Hreflang and canonical tags serve different purposes but work together. A localized page should have both: a canonical pointing to itself (not the default-language version) and hreflang annotations pointing to all sibling pages. Conflicting canonicals and hreflang signals — like canonicalizing es-MX to en-US — will cause Google to ignore the hreflang entirely.
Real-world example
We rebuilt an e-commerce client's locale strategy across 8 regional subdirectories (/en-us/, /en-gb/, /de-de/, /fr-fr/, etc.) on Next.js 14 with App Router. Before hreflang implementation, their German pages were showing in US SERPs and their US pages ranked in Germany — both had thin click-through rates below 1%. We generated hreflang annotations via next-sitemap's transform function, producing ~12,000 sitemap entries with bidirectional <xhtml:link> tags. Within 6 weeks of reindexing, Google Search Console showed a 94% reduction in "no return tag" errors. Organic sessions from correctly matched locales increased 38% in the following quarter.