International SEO tool

Hreflang Generator

Pick a language or language-region code for each version of a page, paste its URL, and get ready-to-use hreflang tags, an hreflang sitemap block or HTTP Link headers, with x-default included.

—

In short: hreflang tells Google which language or regional version of a page to show each searcher. Every version lists all the others plus itself, ideally with an x-default fallback. This hreflang generator writes that full set for you in HTML, sitemap or HTTP header form.

What a correct hreflang tag set looks like

Say you sell the same product to the US, the UK and Germany, and you have a country picker at the root. All three product pages carry the identical block below in their <head>, including the line that points to the page itself:

<link rel="alternate" hreflang="en-US" href="https://example.com/us/shoes/">
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/shoes/">
<link rel="alternate" hreflang="de-DE" href="https://example.com/de/schuhe/">
<link rel="alternate" hreflang="x-default" href="https://example.com/shoes/">

Three rules make or break this. The URLs must be absolute (protocol and host included). Every URL in the set must return 200, be indexable and be its own canonical; a URL that redirects or canonicalizes elsewhere breaks the cluster. And the annotations must be reciprocal: if the German page is missing from the UK page's list, Google can drop the pair. Copy the generated block into every page of the set, not only one.

Valid hreflang codes: language, script and region

The value starts with an ISO 639-1 language code. You can add an ISO 3166-1 alpha-2 region after a hyphen, and for Chinese an ISO 15924 script. Google does not care about letter case, but en-GB (lowercase language, uppercase region) is the convention and easiest to read. The list in this tool only contains combinations that pass those rules.

WrongRightWhy
en-UKen-GBUK is not an ISO 3166-1 code; Great Britain is GB.
usen-USA region on its own is not allowed. The language is always required.
en-EUen or one tag per countryEU is not a country code. Google has no single tag for a group of countries.
zh for both scriptszh-Hans / zh-HantSimplified and Traditional Chinese are different scripts. Use zh-CN, zh-TW or zh-HK when you target a market rather than a script.
es-419es-MX, es-AR…Google documents two-letter regions only, so numeric UN region codes are not a safe choice.
jpjaJP is the country; the Japanese language code is ja. Same trap with dk/da and se/sv.

Use a language-only code when one version serves every country that speaks it. Add a region only when the content really differs, for example prices in GBP versus USD, or different shipping terms. A common pattern is en as a catch-all English page plus en-GB for a UK-specific one; Google sends UK users to en-GB and other English speakers to en.

Hreflang sitemap vs HTML tags vs HTTP headers

All three methods carry the same information, and Google says they are equivalent. Use one of them per page, not a mix, so you only have one place to fix when URLs change.

  • HTML link tags are the default for small and medium sites. With 10 languages that is 11 extra lines on every page, which is fine; at 40 languages the head gets heavy.
  • An hreflang sitemap keeps everything in one file. Each <url> entry has its own <loc> and repeats the full list of xhtml:link alternates, so a set of 4 versions produces 4 entries. The usual sitemap limits of 50,000 URLs and 50 MB uncompressed per file apply. Don't forget the xmlns:xhtml namespace on <urlset>; the sitemap tab above includes it.
  • HTTP Link headers are for files without a <head>, such as PDF brochures in several languages. They are set in the server configuration, for example with add_header Link in nginx.

How to check hreflang after deployment

Search Console no longer has an international targeting report, so testing is on you. Crawl the site with a crawler that reports missing return links, non-200 targets and hreflang URLs that are not canonical. For a spot check, view the source of each version and confirm the block is identical everywhere. Then search a brand query from another country with our local SERP checker and see which URL Google shows. If the wrong version ranks in one market, the cause is almost always a missing return link or a canonical tag pointing to another language.

Frequently asked questions

What does x-default mean in hreflang?

x-default marks the page Google should show when none of your other hreflang values match the searcher's language or region. It usually points to a language selector or to your main international version. It is optional, but recommended on every set of alternates.

Do hreflang tags have to be reciprocal?

Yes. If the English page lists the German page as an alternate, the German page must list the English page too. Google calls these return links. When they are missing, Google may ignore the annotation for that pair. Each page should also include a tag pointing to itself.

Should I put hreflang in the HTML head or in the sitemap?

Google treats both the same, so pick the one that is easier to keep correct. HTML tags are simplest for small sites. An hreflang sitemap is easier for large sites because the tags live in one file and do not add weight to every page. HTTP Link headers are meant for non-HTML files such as PDFs.

Is hreflang en-UK correct?

No. The region part must be an ISO 3166-1 alpha-2 code, and the code for the United Kingdom is GB, so the correct value is en-GB. Similar mistakes are en-EU and a bare country code such as hreflang="de" used to mean Germany; de is the German language, not the country.

Related tools: Meta Tag Generator · Local SERP Checker · Robots.txt Generator