Skip to content

Hreflang Tag Generator

This hreflang tag generator turns a list of language versions of one page into the full set of annotations Google asks for: every version listing itself and all the others, with an optional x-default.

A space, a tab or a comma between the two, so two columns from a spreadsheet paste as they are. Nothing you type leaves your browser.

Output

It checks each code against the ISO 639-1 language and ISO 3166-1 region lists and catches the mistakes that make Google ignore a tag, such as en-uk for the United Kingdom, en_US with an underscore or a country code on its own. Choose HTML link tags, XML sitemap entries for every URL, or an HTTP Link header for PDFs. Everything runs in your browser.

Use this tool often? Bookmark this page, so it is one click away next time.

Email me this result

Want a copy for your records or a client? Leave your email and we'll send you this result. It is written by a real person at Crawl Cove, not an automated blast, so it may take a little while to arrive. We'll only use your address to send it, unless you also tick the box below. Privacy policy.

That email address doesn't look right. Please check it and try again.

Something went wrong saving your address. Your result above is unaffected; please try again.

Got it. We'll email your result to you. Nothing else lands in your inbox unless you ticked the tips box.

How to create hreflang tags

  1. List each version

    One line per language or country version: the code, then the full URL. Two columns pasted from a spreadsheet work as they are.

  2. Fix what is flagged

    Invalid codes, relative URLs and a code used twice are left out and explained, so the output only ever contains tags Google can use.

  3. Choose x-default and a format

    Pick the page for everyone else (often a country picker or the main site), then HTML tags, XML sitemap entries or an HTTP header.

  4. Publish, then check

    Put the same set on every version, then open each version in the hreflang checker, which fetches every alternate and confirms each one links back.

What a complete hreflang set looks like

Hreflang links the language and country versions of one page so Google can show each searcher the right one. Every version carries the whole set: a link to itself and a link to each of the others, each with its code. If the UK page links to the US page but the US page does not link back, Google ignores the pair. That is why the generator writes one block for you to paste on every version rather than a different block per page. x-default is optional and names the page for everyone whose language or country matches none of the others.

Hreflang errors and how to audit them

Valid hreflang codes

A code is a language, optionally followed by a region: "de" for German anywhere, "de-AT" for German in Austria. The language is an ISO 639-1 code and the region an ISO 3166-1 alpha-2 code, joined by a hyphen. The generator checks both against the same lists our hreflang checker uses. The mistakes it catches most: "en-uk", where the United Kingdom is "gb"; an underscore, as in "en_US"; a country on its own, as in "gb", since a region cannot stand without a language; "eu", which is not a country; and "uk" on its own, which is Ukrainian. Codes are not case-sensitive, so "en-GB" and "en-gb" are the same tag.

HTML tags, sitemap or HTTP header?

Google reads hreflang from any of three places, and one is enough. HTML link tags in the head are the simplest for a small site. XML sitemap entries suit large sites and pages you cannot easily edit: each URL gets its own entry that lists the whole set, which this generator writes out for you. The HTTP Link header is for files with no head, such as PDFs. Pick one method per set; two that disagree are harder to debug than either alone.

validate your XML sitemap

Language only, or language and country?

Use a language on its own when one version serves every country that speaks it, and add the region only when you have versions that differ by country, such as prices in pounds and dollars. When you do split a language by country, it helps to add the plain language as well, pointing at your main version, so an English speaker in Ireland or Australia lands on an English page rather than on x-default. The generator notes when a language is split by country with no plain version.

Frequently asked questions

Is this hreflang tag generator free?
Yes. It is free, needs no sign-up, and runs entirely in your browser, so the URLs you paste are never sent anywhere.
What is the hreflang code for the UK?
"en-gb" for English in the United Kingdom. "uk" is the ISO code for Ukrainian, and there is no region "uk", so "en-uk" is invalid and Google ignores it.
Do I need a self-referencing hreflang tag?
Yes. Google asks each version to list itself as well as the others. Pasting the same generated block on every version does that automatically.
Do I need x-default?
No, it is optional. Add it when you have a page that suits everyone else, such as a country picker or your main international site.
Can I put hreflang in my sitemap instead of the HTML?
Yes. Choose XML sitemap and the generator writes a url entry for every version, each carrying the whole set. Use the sitemap or the HTML tags for a set, not both.
How do I check hreflang tags after publishing?
Open one of the pages in the hreflang checker on this site. It reads the tags, fetches every alternate and confirms that each one links back with a matching code.
Can I check hreflang across my whole site?
Not here: this tool writes the tags. Crawl Cove, the desktop crawler, checks hreflang on every page it crawls and in your sitemaps, and it has a permanent Free plan.

From one page to your whole site

This writes the tags for one set of pages. Crawl Cove checks the hreflang on every page it crawls, from the HTML and from your sitemaps, and lists missing return links, invalid codes and alternates that redirect or error. See check hreflang on a live page or check hreflang site-wide.

Download free