Home › Tools › hreflang Tag Generator
hreflang Tag Generator
Generate hreflang annotations as HTML link tags, an HTTP Link header, or sitemap entries — with validation for bad language codes and missing return tags.
SerpPrism's hreflang Tag Generator is a free online tool that builds hreflang annotations for multilingual sites — as HTML link tags, an HTTP Link header, or sitemap entries — and validates language codes and missing return tags as you go. No sign-up is required and everything runs in your browser. It is made for site owners and developers running the same content in more than one language or region. List one line per language version and pick an output format. The generator writes the full cluster for every URL, because that is what the specification actually requires, and it flags the mistakes that make Google silently ignore the whole set.
How to use it
- Enter one line per language version: the code, a pipe, then the full URL of that version.
- Optionally give an
x-defaultURL for visitors whose language is not in the list. - Pick the format you actually ship — head tags, HTTP header, or sitemap — and copy the block.
The return tag is the part almost everyone misses
hreflang is a two-way statement. If your US page points at the German page, the German page has to point back, or Google treats the annotation as unconfirmed and ignores it. This is why a partial rollout — tags added to the English pages but not the translated ones — produces no change in search results whatsoever, and no error message either.
Each page also has to annotate itself. A page that lists only its siblings, and not its own language, is an incomplete cluster. The generator writes the full set including the self-reference precisely so this cannot happen by omission.
x-default is not your main language
It is the fallback for a visitor whose language matches nothing in your list — someone browsing in Portuguese when you publish English, German and Japanese. Pointing it at your English page is common and works, but the more useful target is a page that lets the visitor choose.
It is optional, and Google will not penalise you for leaving it out. It earns its place when you have significant traffic from languages you do not publish in, which is most sites.
Three places to put it — and why you should pick one
HTML <link> tags in the head, the Link HTTP response header, or xhtml:link entries in your XML sitemap. The header exists for non-HTML files — a PDF has no head — and the sitemap exists for sites with too many alternates to fit comfortably in a template.
Mixing them is where it breaks. If one URL carries a different set of alternates in two places, the crawler has to guess which is authoritative, and a guess is worse than a single correct source. Pick one method per URL and keep it consistent across the whole cluster.
Sitemap annotations carry an extra rule: every URL in that sitemap must have its complete cluster, including itself. A sitemap where half the entries are annotated and half are not is worse than none.
Codes that look right and are not
en-UK is the classic one. The ISO 3166-1 code for the United Kingdom is GB, not UK, and while Google is forgiving in practice, other tooling and several CMS plugins are not. en-GB is the value to ship.
Region subtags go uppercase and language subtags lowercase: de-DE, not DE-de or de-de. Google reads the values case-insensitively, so a slip here will not break the annotation, but it will break any downstream tooling that compares strings exactly.
Only annotate canonical, indexable URLs. A hreflang link pointed at a redirected, noindexed or non-canonical URL is dropped, and — depending on how your cluster is built — can take the whole set down with it.
A worked example: three Englishes and a fallback
A site publishes the same guide for the US, the UK and Australia, with prices and spelling differing between them. Three lines go into the generator — en-US | https://example.com/us/guide, en-GB | https://example.com/uk/guide, en-AU | https://example.com/au/guide — plus an x-default of https://example.com/guide for everyone else.
The HTML output is four link tags, and each of the three pages carries all four, including its own: <link rel="alternate" hreflang="en-GB" href="https://example.com/uk/guide" /> appears on the US page, the UK page and the Australian page alike. A page that lists only its siblings is an incomplete cluster, and Google treats it as unconfirmed.
One typo the generator catches before it ships: en-UK. The ISO 3166-1 code for the United Kingdom is GB, not UK, and the tool flags the line and suggests the correction. Google is forgiving about it in practice, but several CMS plugins and validators are not, and the correct code costs nothing.
What this tool deliberately does not do
It does not fetch your URLs. Verifying that each target returns 200, and that each page really does carry the reciprocal tags, means requesting pages on your domain from somewhere other than your browser — which browsers block, and which a privacy-respecting tool should not route through a third party anyway.
It also cannot read the hreflang report in Google Search Console, which is the only place that tells you what Google actually accepted.
Use this to get the cluster correct and complete. Then confirm it with Search Console's international targeting report, or by fetching two of the URLs and checking that each contains the other.
Questions
Should hreflang point to the canonical URL?
Yes. Only annotate self-canonical, indexable URLs. A target that redirects or carries noindex is ignored, which can invalidate the cluster.
Do I need hreflang for a single-language site?
No. It only matters when you serve substantially the same content in more than one language. Adding it to a monolingual site does nothing.
Can I put hreflang in the sitemap and in the HTML at the same time?
You can, but do not. Two sources that disagree leave the crawler guessing. Choose one method per URL set.
Is x-default required?
Not required, but recommended when you have visitors in languages you do not publish. Point it at a language chooser rather than at one language version.
Is my data sent anywhere?
No. Parsing and generation happen in your browser. Nothing you type leaves the page.
What language codes does hreflang use?
Language uses ISO 639-1 two-letter codes (en, de, fr), optionally followed by an ISO 3166-1 region (en-GB, en-US). Codes like "en-UK" or "eng" look plausible but are invalid and get ignored. The generator validates every code you enter and flags the ones crawlers would discard.
What happens if I forget the return tag?
The annotation is ignored. If page A declares page B as its German equivalent, B must declare A back — a one-way link invalidates the pair, and usually the whole cluster. The generator checks for missing return tags before you copy the output.
What is the difference between hreflang and a canonical tag?
A canonical says "this is the one URL to index"; hreflang says "these URLs are equivalents of each other in different languages". They work together: every hreflang target must be self-canonical, or the annotation is dropped.
Do I need hreflang if I only have en-US and en-GB?
Yes, if the content differs between them — spelling, prices, shipping. If the two versions are identical, one canonical page is simpler: hreflang is for equivalent pages, not duplicate ones.
What if my translated pages are on subdomains?
It works the same way: hreflang targets are full URLs, so fr.example.com and example.com/fr are both fine. What matters is that each target is canonical and indexable, and that the return tags exist.
Related tools
Meta Tag Generator
Generate clean page title, meta description, canonical, Open Graph and Twitter card tags.
robots.txt Tester
Paste a robots.txt and test any URL against any user-agent.
llms.txt Generator
Build a valid llms.txt file — the plain-text index that tells AI crawlers what your site offers.
Related guides
What 60 Sites Actually Do With hreflang
We parsed hreflang on 60 high-traffic homepages. Less than half declare it, and a third skip x-default — the tag Google recommends but never requires.
What 55 Homepages Actually Do With Canonical
We fetched the homepage of 78 well-known domains and read 55. Four in five declare a canonical; one in five ships a homepage with none at all.