Hreflang Tag Generator

List each language or regional version of a page and get the hreflang tags for it, in HTML or XML sitemap form — with the code mistakes that quietly break the whole set caught as you type.

Language versions

Where to send visitors whose language matches none of your versions. Usually your main or language-picker page.

What the generator checks

Each row becomes one hreflang annotation. The language must be a real ISO 639-1 code and the region a real ISO 3166-1 alpha-2 code, so the usual mix-ups get caught before they ship: uk for the United Kingdom (that's Ukrainian, you want en-GB), cn for Chinese (that's not a language code, you want zh-CN), jp for Japanese (the language is ja). Duplicate language-region pairs and relative URLs are rejected too, since both invalidate the set.

The output is written for you to paste onto every page in the group, unchanged. That's deliberate: the block always includes a self-referencing tag, which is what makes the annotations reciprocal and therefore valid. Everything runs in your browser and nothing is uploaded.

Frequently asked questions

Does every page need the full set of tags, or just the main one?

Every page in the set needs the complete block, including a tag pointing at itself. Hreflang annotations have to be reciprocal: if your Spanish page claims the English page as an alternate but the English page doesn't claim the Spanish one back, Google ignores the whole relationship. This is by far the most common reason hreflang silently does nothing.

What is x-default actually for?

It's the fallback for visitors whose language and region match none of your versions. A Japanese speaker hitting a site that only has English, Spanish, and German versions gets the x-default page. Most sites point it at their main English page or a language-picker landing page. It's optional, but without it search engines guess.

Can I use a region code on its own, like just GB?

No. Hreflang always needs a language, and the region is optional on top of it. "en-GB" is valid, plain "en" is valid, plain "GB" is not. A related trap: the language part is ISO 639-1 and the region is ISO 3166-1, and they disagree in places. The United Kingdom is GB, not UK, and "uk" on its own is the language code for Ukrainian.

Should these go in the HTML or the sitemap?

Either, but pick one and use it consistently. HTML tags in the head are easier to reason about and to spot-check by viewing source. The XML sitemap form keeps the markup out of your templates entirely and scales better across thousands of URLs, at the cost of being invisible unless you go looking at the sitemap. Don't do both, as conflicting sets are worse than one.

Do hreflang tags help my rankings?

Not by themselves. What they do is make sure the right version of a page gets shown to the right audience, which improves click-through and reduces the bounce that comes from landing on a page in the wrong language. They also stop your regional variants from being treated as duplicate content competing with each other.

Related tools

Command Palette

Search for a command to run...