Hreflang generator
Build hreflang tags for a set of language versions, with the codes and rules checked.
Include the page you are putting these tags on. A set that omits itself is invalid.
Where to send a visitor whose language you do not cover. Usually the selector or the English page.
hreflang tags
Before you ship this
- Note: Add at least two language versions — one is not a set.
How to use it
- Add one row per language version: the locale code, then the absolute URL.
- Include the page you are adding these tags to. A set that omits itself is invalid.
- Add an x-default URL for visitors whose language you do not cover.
- Put the same block on every page in the set — every version must link back, or it drops out.
The tags are easy, the set is not
An individual hreflang link is trivial. What breaks is the set: every version must list every other version, including itself, and every one of those pages must carry the same list back.
A version that does not reciprocate is dropped from the group entirely, which is why hreflang problems usually show up as one language quietly not ranking rather than as an error anywhere.
Codes that look right and are not
en-UK is the classic: UK is not an ISO 3166-1 code, so the tag is ignored. The format is a lowercase ISO 639-1 language, optionally a hyphen and an uppercase ISO 3166-1 region, with an optional script subtag between them for cases like zh-Hant.
Region alone is never valid. There is no hreflang="GB", only a language, optionally qualified by where it is spoken.
It is a clustering signal, not a ranking one
hreflang does not make a page rank better. It tells Google which version to show to which searcher, which usually means swapping one of your pages for another of your pages.
That is still valuable — it stops the American page outranking the British one in Britain — but it will not rescue pages that have nothing else going for them.
Hreflang generator FAQ
What is the correct hreflang code for the UK?
en-GB. en-UK is the most common mistake in international SEO: UK is not an ISO 3166-1 country code, so the tag is invalid and silently ignored.
Does every page need to list itself in hreflang?
Yes. The self-referencing tag is required, and a set missing it is treated as malformed. Every page in the set also needs the full list, pointing back at every other version.
What does x-default do?
It names the page to serve when no language version matches the visitor. Usually a language selector or the most widely understood version. Without it, the engine picks for you.
Should hreflang go in the head, the sitemap or the HTTP headers?
Pick one. Link tags in the head are simplest and are what this tool generates. An XML sitemap is better for a large site, because one file carries the whole cluster and you are not editing every page. Headers are for non-HTML files such as PDFs. Implementing two at once is how sites end up with contradictory sets.
How does hreflang interact with the canonical tag?
Each page canonicals to itself, never to another language. Pointing the French page canonical at the English one tells Google the French page should not be indexed, which removes it from the cluster entirely — a self-inflicted wound that is surprisingly common.
Can I target a country without specifying a language?
No. The language code is required and the region is the optional part, so hreflang=gb is invalid while en-gb is fine. If you genuinely want everyone in one country regardless of language, that is a job for separate pages per language in that region, not for a region-only tag.
Do I need hreflang for two pages in the same language?
Yes, when they target different places — en-GB and en-US pages with different prices, spelling and delivery terms are exactly the case hreflang exists for. Without it, Google picks one and shows it to everybody, usually the one with the stronger links.
What happens if one page does not link back?
That pair is ignored. The annotations have to be reciprocal, so if the German page lists the French one but not the other way round, the relationship simply does not exist as far as the search engine is concerned. This is why the whole set belongs in a template rather than hand-maintained per page.
Does hreflang consolidate ranking signals between versions?
No, and this is the most common misunderstanding. It tells the engine which version to show to which audience; it does not merge their authority the way a canonical does. Each version earns its own links and ranks on its own merits.
How can I check a set is correct?
Crawl it. The international targeting report that used to flag errors in Search Console was retired, so validation now means a crawler that collects every version and checks the return links, or a dedicated hreflang validator. Testing a single page tells you almost nothing, because the errors are relationships between pages.