/tools/hreflang-generator

Hreflang tag generator

Enter your site's address, pick the languages you publish in and a default, and the generator writes the hreflang link tags for the head of your pages, or the matching entries for an XML sitemap, including x-default. It assumes each language version lives in its own folder, such as example.com/de/.

URLs are written as base URL + language code + slash, for example https://www.example.com/de/.

Output format
Languages

How to use the hreflang generator

  1. 1

    Enter the base address of your site without a language folder, for example https://www.example.com.

  2. 2

    Select every language the page exists in. Add region codes such as en-GB or es-MX if you target countries, not only languages.

  3. 3

    Choose the default version for x-default: the page shown to visitors whose language isn't in your list.

  4. 4

    Choose HTML tags or XML sitemap, copy the output and add it to every language version of the page.

How hreflang works

hreflang tells search engines which URLs are language or regional versions of the same page, so they can show each searcher the right one. Three rules matter most: • Every version lists all the versions, including itself. • The links must go both ways: if the German page points to the French page, the French page must point back. • Every URL must be the canonical, indexable version of its page and return status 200. x-default names the page to show when none of the listed languages matches the searcher.

Tags or sitemap?

Both do the same job; use one method per page. Tags in the head are simplest on small sites. Sitemap entries keep the HTML lighter and are easier to maintain with many pages or languages: every language version gets its own url entry listing all the alternates. The generator writes each URL as base address + language code + slash (https://www.example.com/de/); if your site uses subdomains, separate domains or no trailing slash, adjust the URLs before you publish them.

Questions

Which codes can I use?

A two- or three-letter ISO 639-1 language code (de, fr), optionally followed by an ISO 3166-1 country code (de-AT, en-GB). A country on its own is not valid: "uk", for example, means Ukrainian, not the United Kingdom.

Do I need x-default?

It isn't required, but it's recommended. It tells search engines which page to show when none of your languages matches, often the English version or a language picker.

Does hreflang replace canonical tags?

No. Each language version keeps a canonical tag that points to itself. If every version's canonical points to one language, search engines are told to ignore the others.

Why aren't my hreflang tags working?

The usual causes are missing return links, URLs that redirect or return 404, canonical tags that point elsewhere, and invalid codes. Check a few pages with a crawler and with the URL Inspection tool in Google Search Console.