Hreflang is an HTML attribute (also usable in HTTP headers and sitemaps) that links equivalent pages written for different languages or regions. On the English page you say "the German version is over there, the British version is over there", and every other version says the same about the rest.
Google uses these annotations for two things: to understand that the pages are localized variations of the same content, and to show the most appropriate URL in results. A searcher in Vienna searching in German should land on /de/, not on the English original.
The hreflang tag, piece by piece
<link rel="alternate" hreflang="de-AT" href="https://example.com/at/" />
rel="alternate"says the linked URL is an alternate version of this page.hreflang="de-AT"is the audience: an ISO 639-1 language code (de), optionally a hyphen and an ISO 3166-1 alpha-2 region code (AT). An ISO 15924 script can sit in between for languages like Chinese:zh-Hant-TW. The special valuex-defaultmarks the fallback.hrefis the fully qualified URL of that version, protocol included.
Three rules trip people up most. The language always comes first, and a country code alone is invalid: hreflang="be" means Belarusian, not Belgium. Only officially assigned region codes work, so en-UK does nothing (it's en-GB). And numeric areas like es-419 for Latin America aren't supported. Values are case-insensitive.
See who lands where
Toggle the versions a site offers, pick a searcher, and watch which URL they are matched to. The logic follows the order Google describes: the exact language-region version, then the language catch-all, then x-default.
Your versions (toggle them)
Google sends them to
en example.com/en/
No en-AU version, so the language catch-all "en" wins.
Two lessons fall out of playing with it. Remove plain en and the Australian searcher is left without a clear match, which is why Google suggests a catch-all for each language you split by region. Remove x-default and the Japanese searcher gets whatever Google considers best. Hreflang is a strong hint, not a redirect: Google still makes the final call.
Where you stand changing what you see isn't only a search quirk: from Sydney the crescent Moon looks flipped, and ahaboo walks through why it has phases in the first place.
Three ways to implement hreflang
Google treats all three as equivalent. Pick the one that fits how your site is built; using several adds maintenance without any benefit in Search.
1. HTML link elements
A block of <link> elements in the <head> of every version. The most common choice for CMS-driven sites. Build one with the hreflang generator.
2. HTTP Link header
For non-HTML files such as PDFs. Every version returns the same header:
Link: <https://example.com/file.pdf>; rel="alternate"; hreflang="en",
<https://de.example.com/file.pdf>; rel="alternate"; hreflang="de"3. XML sitemap
Each URL gets an <xhtml:link> child for every version, itself included. Best for large sites; the sitemap generator builds the file from URL patterns.
Hreflang best practices
- Every version lists every version, including itself. The block is identical on all pages of the set.
- Return links are mandatory. If page X points to page Y, Y must point back to X, or Google may ignore the pair. The checker fetches each alternate to confirm this.
- Point at canonical, indexable URLs. Each version should be self-canonical and return 200, not redirect. More in hreflang and canonical.
- Add a language catch-all when you split a language by country, e.g.
esalongsidees-ESandes-MX. - Consider x-default for a country selector or global page.
- Don't auto-redirect by guessed language. Google's multi-regional guidance warns that such redirects can stop users and crawlers from reaching all versions. Link between versions instead.
- Localize for real. Hreflang doesn't fix pages that are machine-translated boilerplate around an untranslated body.
When something breaks, the common hreflang errors guide maps each warning to its fix.
A complete hreflang example
A store with a US-English default, a UK store, a German site that also serves Austria and Switzerland, a Swiss-French version and a country selector at the root. This exact block goes on all five pages:
<link rel="alternate" hreflang="en" href="https://shop.example/en/" /> <link rel="alternate" hreflang="en-GB" href="https://shop.example/uk/" /> <link rel="alternate" hreflang="de" href="https://shop.example/de/" /> <link rel="alternate" hreflang="fr-CH" href="https://shop.example/ch-fr/" /> <link rel="alternate" hreflang="x-default" href="https://shop.example/" />
A French speaker in France matches no French catch-all here, so they fall to x-default, the selector. If that's not what you want, add an fr row pointing at the Swiss-French page or a dedicated French one.
Hreflang questions
What is hreflang in simple terms?
Hreflang is an annotation that tells Google a page has equivalent versions for other languages or regions, and which URL is meant for which audience. Google can then show a Spanish speaker the Spanish URL in results instead of the English one.
Is hreflang a ranking factor?
No. It does not make a page rank higher. It helps Google swap in the most appropriate version of a page that already ranks, and it helps Google understand that similar pages in different locales are localized variations rather than unrelated duplicates.
Does Google use hreflang to detect the language of a page?
No. Google says it uses algorithms to determine a page’s language and does not rely on hreflang or the HTML lang attribute for that.
Do I need hreflang if I only translate some pages?
Only on the pages that have equivalents. Google says it is fine to have hreflang on just parts of your site.
Does Bing use hreflang?
Bing has said it treats hreflang as a weak signal and relies more on the content-language meta tag or HTTP header and the HTML lang attribute. Setting those as well costs nothing.
What is the difference between hreflang and the lang attribute?
The lang attribute on <html> declares the language of the current document for browsers and assistive technology. Hreflang points to other URLs and says which audience each one is for.