Getting Hreflang Right
Add a row for each language or region version of a page, and this tool produces the complete set of hreflang link tags, optionally including an x-default fallback. Copy the output into the head of every page in the set.
Hreflang tells search engines that several URLs are the same content in different languages or for different regions, so the right version is shown to the right searcher. It is conceptually simple and, in practice, one of the easiest technical SEO features to get subtly wrong.
What hreflang actually does
It does not change rankings, and it does not make a page rank in a new country. What it does is help search engines swap in the appropriate version of a page that already ranks — so a French searcher sees your French URL rather than the English one.
It also mitigates duplicate content between versions. Two pages of near-identical English for the US and UK markets could otherwise compete with each other; hreflang tells search engines they are regional variants of the same thing rather than duplicates.
Google treats hreflang as a signal rather than a directive. It usually honours a clean, consistent implementation and ignores a contradictory one, which is why correctness matters more here than with most tags.
The rules that trip people up
Hreflang must be reciprocal. If your English page points at the French one, the French page must point back at the English one. Every page in a set must list every version in the set, including itself. A one-directional reference is ignored entirely.
That self-reference requirement surprises people: the English page includes an hreflang tag pointing at the English page. Omitting it is one of the most common implementation errors.
URLs must be absolute, including the protocol, and must point at indexable pages. An hreflang pointing at a URL that redirects, 404s, is blocked in robots.txt, or carries a noindex tag invalidates that entry.
Language and region codes
- Language alone: en, fr, de, ar — the ISO 639-1 two-letter code.
- Language plus region: en-GB, en-US, es-MX, pt-BR — language code, hyphen, ISO 3166-1 Alpha-2 country code.
- The region is a country, never a language. en-UK is wrong; the country code for the United Kingdom is GB.
- Region without language is invalid. There is no such thing as an hreflang of just GB.
- x-default marks the fallback for searchers whose language or region does not match any listed version.
When to use x-default
x-default nominates a version for everyone your other tags do not cover. If you have English, French and German pages, a Japanese searcher matches none of them — x-default tells Google which to show them.
The usual choice is your primary language version, or a language selector page if you have one. It is optional, but on any site with more than a couple of versions it prevents Google guessing.
This tool defaults x-default to the first row's URL, which is a sensible convention if you list your primary version first. Change the ordering if that is not the version you want as the fallback.
Where the tags go
There are three valid places: HTML link tags in the head, HTTP headers, or an XML sitemap. Pick one and use it consistently — mixing methods for the same page set is a common source of conflicting signals.
HTML tags in the head are the most common and the easiest to inspect, which is what this tool generates. For non-HTML files such as PDFs, HTTP headers are the only option. For very large sites, the sitemap method avoids adding dozens of tags to every page.
Hreflang and canonical tags must agree. Each page's canonical should point at itself, not at another language version. A canonical pointing across languages while hreflang says they are alternates is contradictory, and Google will resolve it in a way you did not intend. The Canonical Tag Generator produces the self-referencing tags each version needs.
Common hreflang mistakes
- Missing self-referencing tags, so the set is never treated as complete.
- Non-reciprocal references, where A points to B but B does not point back.
- Using a language code where a country code belongs, most often en-UK instead of en-GB.
- Relative URLs, which resolve unpredictably and frequently break.
- Pointing hreflang at URLs that redirect or are blocked from indexing.
- Canonical tags pointing across language versions instead of self-referencing.
- Adding hreflang for a language version that does not actually exist yet.
Checking your implementation
Search Console's International Targeting report flags missing return tags and unknown language codes across the site, which is the fastest way to catch reciprocity errors at scale.
For individual pages, view source and confirm the full set is present, including the self-reference. The On-Page SEO Analyzer will confirm each target URL returns a clean 200 and is not carrying a noindex tag, and the Redirect Chain Checker will confirm none of them redirect.
Frequently asked questions
Do I need hreflang if my site is only in one language?
No. Hreflang exists to connect alternate language or regional versions of the same content. A single-language site with no regional variants has nothing to connect.
Does every page need to reference itself?
Yes. Each page in a set must include an hreflang tag pointing at its own URL alongside the tags for the other versions. Omitting the self-reference is one of the most common implementation errors.
What is the difference between en-GB and en-UK?
en-GB is correct and en-UK is invalid. The region portion uses ISO 3166-1 Alpha-2 country codes, and the code for the United Kingdom is GB. Invalid codes cause the whole tag to be ignored.
Should the canonical point to the same language version?
Yes. Each version's canonical should point at itself. A canonical pointing at a different language version contradicts your hreflang tags and tells Google to consolidate the versions rather than treat them as alternates.
Does hreflang improve rankings?
No. It helps search engines serve the correct existing version to each audience and reduces duplicate-content conflicts between near-identical regional pages. It does not create rankings in a new market.