Skip to content
Free web tool

Hreflang tag generator

This hreflang tag generator writes the link tags that tell search engines which language or regional version of a page to show each visitor. It is for sites with translated or country-specific pages.

  • Runs in your browser
  • Free, no account needed
  • Copy or download the result
Private: runs on this device

Input

143 characters

Result

<link rel="alternate" hreflang="en-US" href="https://www.example.com/en-us/" />
<link rel="alternate" hreflang="en-GB" href="https://www.example.com/en-gb/" />
<link rel="alternate" hreflang="fr" href="https://www.example.com/fr/" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/" />

Put this same full set in the <head> of every page listed, including the page itself. Each page must link back to all the others, or search engines may ignore the tags.

Example

Input
en-US, https://www.example.com/en-us/
en-GB, https://www.example.com/en-gb/
fr, https://www.example.com/fr/
x-default, https://www.example.com/
Result
<link rel="alternate" hreflang="en-US" href="https://www.example.com/en-us/" />
<link rel="alternate" hreflang="en-GB" href="https://www.example.com/en-gb/" />
<link rel="alternate" hreflang="fr" href="https://www.example.com/fr/" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/" />

Put this same full set in the <head> of every page listed, including the page itself. Each page must link back to all the others, or search engines may ignore the tags.

How to use the hreflang tag generator

  1. Enter one line per version in the input box: a code, a comma and a URL, such as fr-CA, https://www.example.com/fr-ca/.
  2. Add an x-default line for visitors who match none of the versions.
  3. Press Run.
  4. Use Copy result and add the same set of tags to every listed page.

How it works

Codes are checked for format: a 2 or 3 letter language, an optional 4 letter script and an optional 2 letter or 3 digit region, or x-default. Letter case is normalized, as in zh-Hant-TW.

The tool cannot confirm that a code is a real, assigned language or country, but it flags common mistakes such as UK instead of GB and underscores instead of hyphens.

Each code may appear only once, and every URL must be absolute.

Every page in the set must list all the alternates, including itself, or search engines may ignore the tags.

Everything runs in your browser. Your input is not uploaded or stored.

Questions and answers

What is x-default in hreflang?

It marks the page to show when no listed language or region matches the visitor, often a language picker or the main site.

Is en-UK a valid hreflang code?

No. The region code for the United Kingdom is GB, so use en-GB.

Does each page need to list itself?

Yes. Every version should carry the full set of hreflang tags, including one that points to its own URL.

All 220 SnowRock tools