Hreflang Generator

Paste your language versions and get the complete, reciprocal hreflang block — as link tags, HTTP headers or sitemap XML.

One per line: a language code, a space, then the full URL. Region codes like en-GB or es-MX are allowed, and the region must be uppercase.
x-default is the page shown to a visitor whose language you do not have. A language selector is the ideal target; your main version is the usual one.
The same block goes on every version, including the page itself. That self-reference is required, not optional.
Hreflang block

          

Nothing you type here is uploaded, stored or sent anywhere. It all runs in your browser.

The three mistakes that break an hreflang cluster

  • No return tag. If page A says "the Russian version is B" but B does not say "the English version is A", Google ignores the pair entirely. Every page in the cluster must carry the whole block, including a tag pointing at itself. That is why this tool prints the same block for every URL — it is the same block.
  • Relative URLs. /ru/pricing is silently dropped. Hreflang URLs must be absolute, with the protocol and the host.
  • A region code used as a language code. hreflang="uk" is Ukrainian, not the United Kingdom. British English is en-GB. This is the single most common error in the wild, and it sends your UK page to Kyiv.

Where to put it

Pick one of three places and use only that one. Link tags in the <head> are the normal choice. HTTP Link: headers are for files that have no head — a PDF, an image. Sitemap annotations are the least painful option when you have thousands of URLs, because you edit one file instead of thousands. Declaring hreflang in two places at once is not an error, but it doubles the surface area for the two to disagree, and when they disagree Google picks the one you did not mean.

Hreflang does not do what people hope it does

It does not stop translated pages competing with each other in the sense of one outranking another — that is not a thing that happens between languages. It does not consolidate ranking signals the way a canonical does; each version ranks on its own merits and needs its own links. What it does is narrow: it tells Google that these URLs are the same page in different languages, so the right one is served to the right searcher. That is worth having, and it is all it is.

The canonical trap

Each language version canonicalises to itself, never to the English original. A Russian page whose canonical points at the English URL is telling Google the Russian page should not be indexed at all, and the hreflang cluster will not save it. If you take one thing from this page, take that one.

Questions people ask

Do I need hreflang if my site is only in one language?

No. Hreflang exists to disambiguate between versions of the same page. With one version there is nothing to disambiguate, and adding self-referencing hreflang tags to a monolingual site does nothing at all — neither good nor bad.

Is the region code required?

No, and most sites should not use one. es serves every Spanish speaker. es-MX serves Spanish speakers in Mexico only. Use a region code when you genuinely have country-specific content — different prices, different shipping, different law — and not because the content was written in a particular country.

Why does Search Console say "no return tags"?

Because the page you pointed at does not point back. Fetch that page and look at its rendered head. The usual causes are a cluster built only on the source language, a trailing-slash mismatch between the two URLs, or hreflang injected by JavaScript that Google did not execute.

Does the order of the tags matter?

No. Google reads the whole set. The one rule about position is that link tags belong in the <head> — an hreflang tag that ends up in the <body>, which is what happens when a tag earlier in the head is malformed, is ignored.

Is anything I paste here sent anywhere?

No. This page has no backend. The parsing and the generating happen in your browser, and nothing is uploaded, logged or stored.

Translated pages still need links

Hreflang tells Google which version to show. It does not tell Google the page is worth showing. That part is links.

Book a Call More free tools