What is hreflang and why it matters
Hreflang is an HTML attribute that tells search engines โ primarily Google โ which language and regional version of a page to show to which user. Without it, Google guesses. And when Google guesses wrong, a German user lands on your Italian page, bounces immediately, and you lose the ranking signal.
For any website targeting more than one language or country, hreflang is not optional. It is the foundation of international SEO. Yet most websites either don't implement it at all, or implement it incorrectly โ missing the x-default, using wrong country codes, or building an incomplete matrix.
The hreflang attribute โ syntax explained
Hreflang tags live in the <head> section of your HTML. Each tag declares one language or locale variant of the current page. A complete implementation looks like this:
The language code follows ISO 639-1 (two-letter codes: it, de, en, fr). You can combine language and country codes for regional targeting: en-gb for British English, de-at for Austrian German.
Common hreflang mistakes
The most damaging mistakes in hreflang implementation โ and the ones Google's John Mueller has flagged repeatedly โ are:
- Missing x-default โ The x-default tag tells Google which page to show when no language match is found. Without it, Google may show the wrong version to users whose language you don't explicitly target.
- Incomplete matrix โ Every page that declares an alternate must also point back. If your Italian page says โmy German version is de.example.com/pageโ, that German page must say โmy Italian version is example.com/pageโ. Broken matrices cause Google to ignore the entire set.
- Wrong country codes โ Using
ukinstead ofgbfor Great Britain is a common error. The country portion uses ISO 3166-1 alpha-2 codes, not generic abbreviations. - HTTP vs HTTPS inconsistency โ All URLs in your hreflang tags must use the same protocol as the canonical version of the page.
How Google uses hreflang to decide which version to show
Google doesn't simply obey hreflang tags โ it treats them as a strong signal, not a directive. The process works roughly like this: when a user searches on Google.de, Google looks for pages with hreflang="de" or hreflang="de-de". If it finds a confirmed match (the tag is present on both the source and destination page), it shows that version in the search results.
Google also uses the user's location, browser language settings, and search query language as signals. Hreflang is the mechanism that lets you tell Google explicitly which page to serve โ rather than leaving it to these inferred signals.
hreflang vs canonical โ when to use which
These two tags solve different problems and must be used together, not instead of each other. The canonical tag tells Google which version of a page is the primary one when you have duplicate or near-duplicate content. The hreflang tag tells Google which language version of a page to serve to which user.
For multilingual sites, every language version should have its own canonical pointing to itself, plus a complete hreflang matrix. The canonical prevents duplicate content penalties; the hreflang ensures the right language is served.
How to implement hreflang without touching your CMS
Traditional implementation requires modifying every page template in your CMS โ adding the hreflang tags to the <head> section and keeping the matrix in sync as you add or remove language versions. For large sites, this is error-prone and expensive to maintain.
The modern alternative is to inject hreflang at the network edge, using a proxy or CDN function that intercepts the response and appends the tags before the browser receives the HTML. This approach works with any CMS, any hosting provider, and requires zero changes to your existing codebase.