Hreflang Tags: Syntax, Rules and Common Mistakes
How hreflang tags work: exact syntax, x-default, canonical tags and the mistakes that make Google ignore them. Includes valid code examples.
Updated · 7 min read
Hreflang tags tell search engines which language or regional versions of a page exist, so each searcher can be shown the right one. Every version must list itself and all the others with absolute URLs and valid ISO language codes, and the pages must link to each other, or Google ignores the tags. Google treats hreflang as a hint, not a command.
Your site is translated and every language loads. Yet Google keeps sending French visitors to your English pages, or indexes only one language. Usually the cause is a missing or broken hreflang.
This guide covers what hreflang does, its rules, and the mistakes that make Google ignore it. To test your own site as you read, use our free multilingual SEO checker.
What hreflang is
hreflang is an attribute on a <link> tag that tells search engines: "this page also exists in these other languages, at these URLs". Google then shows each searcher the version in their language, and treats the versions as one group rather than competing pages.
A typical block, placed in the <head> of every language version:
<link rel="alternate" hreflang="en" href="https://example.com/en/pricing/" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/pricing/" />
<link rel="alternate" hreflang="de" href="https://example.com/de/pricing/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing/" />
Hreflang is a hint, not a command. Get one rule wrong and it is ignored.
Why it matters
Without hreflang, three things tend to happen:
- The wrong language shows up in search. A German visitor lands on your Spanish page, does not understand it and leaves.
- Versions get clustered. Google may group near-identical pages and show only one of them, so your other languages lose visibility.
- New markets stay invisible. Competitors with a clean setup take the rankings you translated for.
Does Google need hreflang to detect the language?
Google says it does not use hreflang or the HTML lang attribute to detect the language of a page: it uses its own algorithms for that (Google Search Central). John Mueller has also said that when pages are in different languages, Google can usually figure that out without hreflang.
What hreflang does is tell Google which versions are alternates of each other, so it can show the right one to each searcher. Google also states that translated pages are only considered duplicates if the main content stays untranslated, and it documents translating only the template (menu and footer) as a case where hreflang is useful (Google Search Central).
Search engines treat the signal differently. Search Engine Land reports that Google reiterated in May 2025 that hreflang signals are hints, so canonicals, site structure and content can lead it to show another version. Bing considers hreflang a weak signal and relies more on the content-language attribute, links and visitors, but still recommends using it.
The rules
Reciprocity
If the English page lists the French page, the French page must list the English page back. Otherwise Google discards the pairing. The easy fix is to output the same block on every version.
Absolute URLs
Always use the full URL with protocol and host: https://example.com/fr/, never /fr/. It must match your live URLs exactly, including https and www.
Self-reference
Each page includes itself in the block: the French page lists hreflang="fr" pointing to its own URL.
Valid ISO codes
The language is an ISO 639-1 code (en, fr, de), optionally followed by a hyphen and an ISO 3166-1 region (en-GB, pt-BR, es-MX). A region on its own is not valid. These are the mistakes we see most:
| Wrong | Correct |
|---|---|
en-UK | en-GB |
jp | ja |
cn | zh or zh-CN |
kr | ko |
dk | da |
gr | el |
cz | cs |
ua | uk (Ukrainian, not the UK) |
en_US | en-US (hyphen, not underscore) |
An invalid code means that single tag is dropped.
Unsupported codes: es-419, UK and region-only
Google only supports ISO 639-1 language codes and ISO 3166-1 alpha-2 region codes. Other codes, such as es-419 for Latin American Spanish, are not supported. Unofficial region codes such as EU, UN or UK have no effect on Google Search. Use GB for the United Kingdom. If you serve Latin America, use the specific country codes (for example es-MX) or plain es.
If maintaining a full set of two-way links is hard, Google allows you to omit some languages on some pages, and it will still process the ones that point to each other (Google Search Central).
x-default
x-default tells Google which page to show when none of your languages match the searcher. It is not strictly required, but leaving it out lets Google guess. Add it to the block on every language version, just like the other entries.
Three ways to implement hreflang
Google recognises three methods: HTML <head>, HTTP header and XML sitemap. They are equivalent from Google's perspective, so choose the one most convenient for your site.
- In the HTML
<head>. A<link>tag for each version, like the block above. - In the XML sitemap. Each
<url>lists its alternates withxhtml:linkelements. - In the HTTP
Linkheader. Google notes it is useful for non-HTML files, such as PDFs.
Pick one method. Using all three at once brings no advantage in Search and makes maintenance harder (Google Search Central).
Hreflang and canonical tags
This is where most multilingual sites break. The canonical says "this is the preferred URL for this page". Hreflang says "these other URLs are the same page in other languages". They answer different questions.
The rule: every language version has a canonical that points to itself.
<!-- On https://example.com/fr/pricing/ -->
<link rel="canonical" href="https://example.com/fr/pricing/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/pricing/" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/pricing/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing/" />
If the French page's canonical points to the English page, Google treats the French page as a duplicate, follows the canonical and ignores the hreflang. Translations are not duplicate content, so a cross-language canonical protects nothing.
Don't forget html lang
The <html lang="fr"> attribute declares the language of the page itself. It does not replace hreflang, but it should match the code you use for that page in the block. A French page that says lang="en" sends mixed signals.
Typical mistakes
- Return links missing between some language pairs.
- Relative URLs, or URLs that redirect or return 404.
- A canonical pointing to the original language on every translation.
- Hreflang on a site where every language shares one URL (JavaScript or
?lang=switching). There is nothing real to point to.
Run a page through the multilingual SEO checker to catch these mistakes on your own site.
How to check your hreflang
Open a translated page, view the source (Ctrl+U or Cmd+Option+U) and search for hreflang and canonical. Then open one of the listed URLs and confirm it links back.
That gets slow beyond a few pages. The quicker route is to run a page through our free multilingual SEO checker. It validates hreflang in the head and HTTP header (codes, absolute URLs, self-reference, x-default, duplicates), compares it with html lang, checks the canonical, and visits up to six translated versions to confirm they load, link back and declare their language. For everything beyond hreflang, follow our multilingual SEO audit checklist.
How Lantis handles hreflang
Writing hreflang by hand on a 50-page site in four languages means hundreds of tags to keep in sync. Lantis serves each language on its own URL (a subfolder like /fr/) and adds hreflang for every language plus x-default, the correct html lang and a self-referencing canonical automatically, on Framer, Webflow, WordPress, Shopify or any site with one line of code. Translation is done by AI, with a visual editor and a glossary.
It costs from $3.50/month per language ($3 from two languages, $2.50 from ten), and the first 100 translations are free with no card (see pricing). On Framer, install the Lantis plugin. See the step-by-step guides for Framer and Webflow.
Frequently asked questions
Why does Google ignore my hreflang tags?
Check the return links first: if two pages don't point to each other, Google ignores the tags. Check also for relative URLs, invalid codes and canonicals pointing to another language.
Does hreflang need a language code for x-default?
No. Google says there is no need to specify a language code for x-default, since that page has no specific language. It is used when no other language or region matches the user's browser setting, typically for a language selector page.
How do I handle hreflang and canonical tags with AI translation?
Treat AI translations like any other language version: each one on its own URL, with a self-referencing canonical and the same hreflang block as the other versions. Google considers localized pages duplicates only if the main content remains untranslated.
Do the hreflang URLs have to be absolute?
Yes. Alternate URLs must be fully qualified, including http or https. A relative path like /fr/ does not work.
Is hreflang a ranking factor?
Not directly. It decides which language version Google shows each searcher, which improves clicks in every market and stops versions being clustered together.
Do I need x-default?
It is strongly recommended. Without it, Google has to guess what to show people whose language you do not cover. Point it to your main language or a language selector page.
Should I use en-GB or just en?
Use en if you have one English version for everyone. Add regions like en-GB and en-US only when you have separate versions for each country, such as different prices or spelling.
More on multilingual SEO in our guides.
Also available in Français · Deutsch · Italiano · Português · हिन्दी · Русский · 日本語 · 한국어 · Türkçe · Bahasa Indonesia · العربية