Skip to content

SEO tool

Hreflang Tag Generator

List each language version of a page and get the hreflang tags as HTML, XML sitemap entries or an HTTP header.

Runs entirely in your browser. Nothing you paste is uploaded.

Output as

Hreflang Tag Generator by YegappanFree tool. Open the full page for the guide.

How to use the Hreflang Tag Generator

  1. Add one row for each version of the page: its full address and its language, or language and country.
  2. Choose a fallback page for visitors whose language you do not cover. It becomes the x-default tag.
  3. Choose HTML tags, XML sitemap or HTTP header, copy the code, and add the same set to every version.

How hreflang tags work

A hreflang tag generator writes the tags that tell search engines which language or country each version of a page is for. This hreflang generator checks every code as you type and outputs the tags in the three places they are accepted: the HTML head, an XML sitemap or an HTTP header.

A code is a language, such as en, optionally followed by a country, such as en-GB. The country must be a real country code: en-UK is a common mistake (the code is GB), and regions such as EU or LATAM are not accepted. The tool rejects those and fixes the letter case.

Hreflang only works when the pages point at each other. Every version has to carry the full set of tags, including a tag for itself. If page A names page B but B does not name A, the tags are ignored.

The x-default tag names the page to show when none of the listed languages match the visitor, often the English page or a language chooser.

Use one method per page. HTML tags suit most sites, an XML sitemap keeps large sites lighter, and the HTTP header is for files without a head, such as PDFs.

Common questions

How do I generate hreflang tags?

Add each version's address and language code, choose the output format and copy the code. Then place the same set of tags on every version.

What is x-default in hreflang?

It marks the fallback page for visitors whose language or country is not covered by any other tag.

Is en-UK a valid hreflang code?

No. The country code for the United Kingdom is GB, so the correct value is en-GB.

Do I need a self-referencing hreflang tag?

Yes. Each page lists every version including itself. The set this tool makes already includes it.

Should hreflang go in the HTML or the sitemap?

Either works, but use only one. HTML is simplest for small sites. A sitemap avoids adding many tags to every page on large sites.

Does hreflang replace the canonical tag?

No. Each language version should have a canonical tag that points to itself, alongside its hreflang tags.

Guides for the Hreflang Tag Generator

Related tools