Hreflang Tag Generator
Add a row for each language version of your page and get the markup for all of them — as link tags, sitemap entries or an HTTP header. Every code is checked against the standards Google reads, so the mistakes that make hreflang fail silently get caught here instead of in production.
Your language versions
One row per version of the page, including the one you’re on.
English
English (United Kingdom)
German
French (Canada)
Fallback for everyone else
Nothing here is uploaded — the codes are checked in your browser.
Goes in the <head> of every URL listed above — the same block on each one, unchanged.
<link rel="alternate" hreflang="en" href="https://example.com/" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />
<link rel="alternate" hreflang="de" href="https://example.com/de/" />
<link rel="alternate" hreflang="fr-CA" href="https://example.com/fr-ca/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />Will Google use this?
Every version lists itself
The block below names all of your URLs, so the copy on any one of them includes itself — which is what Google requires.
Every version points back
Paste the identical block onto all 4 URLs. If two pages don't both point at each other, Google ignores the annotation.
x-default set
Visitors who match none of your versions land here.
Codes are valid
Language from ISO 639-1, region from ISO 3166-1 alpha-2. Invalid codes are ignored rather than reported.
Share this result
Posts the numbers below and nothing you typed or pasted, and you get to edit it before it goes out.
“Generated hreflang tags for 5 language versions, every code valid and every version listing the others. It's the reciprocation and the region codes that quietly break this.”
What hreflang actually does
hreflang doesn’t help a page rank. It decides which of your pages ranks, for a person whose language and country Google already knows. If you publish one site in one language, you don’t need it. If you publish the same page in four languages, you have four pages competing for the same meaning, and hreflang is how you tell Google they’re the same thing rather than four attempts at it.
The mechanism is a set of annotations, and the word set is the whole difficulty. Every version has to list every other version and itself, on every page. Google’s documentation on localized versions puts it plainly: “Each language version must list itself as well as all other language versions.”
Why hreflang fails silently
Nothing about a broken annotation looks broken. The page renders, the tags are in the source, validators mostly shrug, and Google simply ignores what it can’t use. There is no error, no report and no warning — which is why hreflang is so often wrong on sites whose owners believe it’s working.
Four failures account for most of it.
1. A code that isn’t in the standard
The language is an ISO 639-1 code and the optional region is an ISO 3166-1 Alpha 2 code. The famous casualty is en-UK: the country code for the United Kingdom is GB, and Google states that “using EU, UN, or UK in hreflangannotations doesn’t have an effect on Google Search”. Close behind are en_USwith an underscore, copied out of a codebase where that’s the correct locale format, and three-letter codes like eng from ISO 639-2.
2. A country code on its own
hreflang="us"looks like it should mean “the American version” and means nothing. Google is explicit: “You can’t specify the country code by itself. The first code stands for the language and Google doesn’t automatically derive the language from a country code.” American English is en-US. A version for everybody in the United States, whatever they speak, isn’t a thing hreflang can describe.
3. A missing self-reference
The English page has to include the tag pointing at the English page. It feels redundant and it isn’t optional. This is why the tool above generates one block containing every URL — the same block goes on every one of them, unchanged, and the self-reference takes care of itself.
4. A missing return link
If your English page names the German page as an alternate but the German page doesn’t name the English one, the annotation is discarded. Google explains the reasoning: “If two pages don’t both point to each other, the tags will be ignored. This is so that someone on another site can’t arbitrarily create a tag naming itself as an alternative version of one of your pages.”
In practice this is where translation projects fall over — not in the markup, but in the deployment. One locale ships a week late with an older template, and the whole set stops working until somebody notices.
Tags, sitemap or header — pick one
All three carry the same information and Google accepts any of them. Doing two isn’t twice as safe; it’s two things to keep in sync, and they will drift.
- Link tags in the
<head>are the simplest and the easiest to check by viewing source. They add weight to every page, which starts to matter at a few dozen versions. - An XML sitemap keeps the annotations out of your templates entirely, which is much easier to maintain across hundreds of URLs — and much easier to get wrong quietly, since nobody reads a sitemap by eye.
- The HTTP header exists for files with no
<head>to put tags in. In practice that means PDFs.
What hreflang can’t fix
An annotation pointing at a page that redirects, carries a noindex, or is blocked in robots.txt does nothing useful — Google can’t serve a version it won’t index. And hreflang says nothing about whether the version is any good: a machine-translated page that nobody links to will be correctly identified as the Spanish version and will still not rank.
Those are site-wide questions and they need a crawl. Site Audit reports the redirects, noindex tags and broken links across every page it finds, and rank tracking is how you find out whether the localized version actually took over in its own country — which is the only real proof any of this worked.
If you’re deciding which markets to translate into rather than wiring up the ones you have, the keyword gap guide covers the step before this one: working out where the demand is before you pay a translator.
Questions
- What is an hreflang tag?
- It's a link element that tells Google another URL is the same page in a different language or for a different country. You put one for every version — including the page itself — on every version, and Google uses the set to serve the right one to the right person.
- Is hreflang a ranking factor?
- No. It doesn't make a page rank higher. It affects which of your existing versions gets shown to a given searcher, which matters if you have a Spanish page outranking your Mexican one in Mexico, and doesn't matter at all if you only publish in one language.
- Why is en-UK wrong?
- Because the country code for the United Kingdom is GB, not UK. Google's documentation says using EU, UN or UK in hreflang annotations doesn't have an effect on Google Search. It's the most common hreflang mistake there is, because UK is the correct abbreviation in ordinary English and the wrong one in the standard.
- Can I use a country code on its own, like hreflang="us"?
- No. Google's documentation says you can't specify the country code by itself, because the first code is always the language and Google doesn't derive a language from a country. A page for American English is en-US, and a page for everyone in the US regardless of language isn't something hreflang can express.
- Do I need x-default?
- It's optional. x-default is the version shown when none of your others match the visitor, and Google says it was designed for language selector pages, so it works best when you have one. If you don't set it, someone who matches nothing gets whichever version Google judges closest.
- Should I use the HTML tags, the sitemap or the HTTP header?
- Pick one. All three carry the same information and Google reads all three, so doing two is duplicated work you then have to keep in sync. Tags in the head are simplest for a small set of pages; a sitemap keeps the markup out of your templates and is easier to maintain across hundreds of URLs; the HTTP header is for files with no head, such as PDFs.
- Why isn't my hreflang working?
- The usual cause is a missing return link. Google ignores annotations that aren't reciprocal — if your English page points at the German one but the German page doesn't point back, the whole set is discarded. After that, the common causes are invalid codes, relative URLs, and pointing at URLs that redirect or are blocked from indexing.
- Is this tool free?
- Yes, with no signup, no limit and nothing uploaded. The codes are validated in your browser against the ISO tables, and the markup is generated there too.
More free tools
- SERP Snippet PreviewSee where Google cuts your title and meta description — measured in pixels, not characters.
- Keyword Clustering ToolTurn a keyword export into groups you could write a page for — in your browser, with the list never leaving it.
- Striking Distance Keyword FinderDrop in a Search Console export and see the queries sitting just off page one, sorted by what they're already earning.
- Keyword Cannibalization CheckerFind the queries where two of your own pages are competing, and see how the impressions are split between them.
- CTR Curve CalculatorBuild a click-through-rate curve from your own Search Console data instead of trusting someone else's study.
The tags are right. Are the pages?
hreflang only helps pages that Google can crawl, index and already ranks. Site Audit checks every URL for the redirects, noindex tags and broken links that quietly undo a translation project.