HomeTools › hreflang Tag Generator

hreflang Tag Generator

Generate hreflang annotations as HTML link tags, an HTTP Link header, or XML sitemap entries — with real validation for bad language codes, duplicate entries and the missing return tag.

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

  1. Enter one line per language version: the code, a pipe, then the full URL of that version.
  2. Optionally give an x-default URL for visitors whose language is not in the list.
  3. 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.

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.

Related tools