331+ free tools. No sign-up. No hidden fees. Explore the toolkit

Hreflang Tag Generator

If your site has the same page in more than one language, hreflang tags tell search engines which version to show each visitor — the English page to readers in the US, the Spanish page to readers in Spain, and so on. Without them, Google may show the wrong language version, or treat your translations as duplicate content.

Add each language version of your page, include an x-default fallback if you have one, and copy the link tags for your page head — or the XML sitemap snippet — ready to paste.

The fallback page shown when no language version matches — usually your homepage or a language-picker page. Only used when the box above is checked.

Your Hreflang Tags

Save to Pinterest

How It Works

A hreflang tag is a <link> element in a page's <head> that points to another language or region version of the same page. Each tag has two parts: the hreflang value — a language code such as en, optionally with a region code such as en-GB — and the href, the full URL of that version. Google reads these tags and shows each searcher the version that matches their language and location. The head carries other tags too — a meta tags generator builds the title, description and social tags.

Hreflang links must be reciprocal: every version of a page should link to every other version, including itself. The x-default value is a special case — it names the fallback page for visitors whose language matches no version, such as a global homepage or a language picker. This generator builds both delivery formats: link tags for your page head, and an XML sitemap snippet where each <url> block lists all of its alternate versions. Use one format consistently; mixing them risks contradictions.

Worked Example

A site with an English page at https://example.com/ and a Spanish page at https://example.com/es/, with the English homepage as the x-default fallback, produces exactly these link tags:

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

Paste the same three tags into the <head> of both pages — each page links to itself and to the other version, plus the fallback.

How to Use This Tool

Add one row per language version of your page, then copy the output that fits your setup.

  1. Add a row for each version. Choose the language from the dropdown, add a region code if the version targets one country (US, GB, ES), and paste the full URL of that version.
  2. Set x-default if you have a fallback page. Keep the box checked and enter its URL — usually your homepage or a language picker. Uncheck it if you have no fallback page.
  3. Generate and copy. Click Generate Hreflang Tags, then copy the link tags into the <head> of every version of the page, or copy the sitemap snippet into your sitemap.xml.
  4. Repeat for every translated page. Hreflang is per-page, not per-site: each translated page needs its own set of tags pointing at its own versions.

Tips and Practical Advice

Frequently Asked Questions

What is a hreflang tag?

A hreflang tag is a link element in a page's <head> that tells search engines which language and region version of the page to show each visitor. For example, hreflang="es" on your English page points Google to the Spanish version, so Spanish-speaking searchers see that version in their results.

Do I need hreflang on every language version?

Yes. Hreflang links must be reciprocal: every version of a page should link to every other version, including itself. If page A links to page B but B does not link back, Google may ignore both tags.

What is x-default for?

x-default names the fallback page Google shows when no language version matches the visitor — for example a global homepage or a language-picker page. It is optional, but recommended for sites with a generic landing page.

Should I use hreflang tags or a sitemap?

Both work — they carry the same information. Link tags in the page head are easiest for small sites; a sitemap is better when you have many pages or cannot edit page templates. Use one method consistently, not both at once, to avoid contradictions.

Should the region code be uppercase?

Yes, by convention: the language code is lowercase ISO 639-1 (en, es, fr) and the region code is uppercase ISO 3166-1 alpha-2 (US, GB, ES), joined with a hyphen — en-US, es-ES, fr-CA. Google accepts other casings, but the standard form is clearest.

Last updated: