Skip to content
kitify
Esc
↑ ↓ to moveEnter to open

Hreflang tag generator

List each language or country version of your page. Every code is checked as you type, and you get tags ready for HTML, your sitemap or HTTP headers.

Your page versions

One row per language or country version of the same page.

English

English (United Kingdom)

German

Spanish (Mexico)

5 valid tags, ready to paste.

<link rel="alternate" hreflang="en" href="https://example.com/" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />
<link rel="alternate" hreflang="de" href="https://example.com/de/" />
<link rel="alternate" hreflang="es-MX" href="https://example.com/mx/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

Paste inside the <head> of every page listed.

  • You target Spanish only in specific countries. Add a plain “es” version so Spanish speakers elsewhere get the right page.
  • Put the same full set of tags on every version listed, including each page's link to itself. Google ignores hreflang that isn't returned by the other page.

What hreflang does

Hreflang tells Google that several pages are the same content in different languages or for different countries, so it shows each searcher the right one. A UK shopper sees your en-GB page with prices in pounds; a shopper in Mexico sees es-MX. It doesn't improve rankings by itself. It makes sure the version that ranks is the right one.

Hreflang code format

  • Language first, as an ISO 639-1 code: en, de, ja, zh.
  • Optionally a country, as an ISO 3166-1 alpha-2 code: en-GB, es-MX, fr-CA.
  • Never a country alone. hreflang="us" is invalid; use en-US.
Common mistakeCorrect
en_USen-US (hyphen, not underscore)
en-UKen-GB (the UK's code is GB)
jpja (jp is the country; the language is ja)
cnzh, or zh-CN for mainland China
es-419Google only reads two-letter countries: list es-MX, es-AR and so on

Three rules Google checks

  1. Return links. If page A points to page B, page B must point back to A. One-way hreflang is ignored.
  2. Self-reference. Each page includes a tag pointing to itself, which the generated set already does.
  3. x-default. Name a fallback for everyone else, usually your main page or a language picker.

HTML, sitemap or header?

All three work the same for Google; pick one and use it consistently. HTML tags in the <head> are easiest for small sites. The XML sitemap is easier to keep in sync for large sites. HTTP headers are the only option for PDFs and other non-HTML files.

Questions people ask

What is x-default in hreflang?

The page for visitors whose language or country you haven't listed. It's often your main homepage or a language picker.

Is it en-UK or en-GB?

en-GB. Hreflang uses ISO country codes, and the United Kingdom's code is GB.

Do I need hreflang if I only have one language?

No. Hreflang is only for sites with the same content in more than one language or for more than one country.

Does hreflang affect rankings?

Not directly. It helps Google show the right version to each searcher, which can improve clicks and stop your own versions competing.

Can I put hreflang in my sitemap instead?

Yes. Choose XML sitemap above. Each URL lists all its alternates with xhtml:link tags.