Generate the hreflang tags for your versions

Enter the equivalent pages of a multilingual site, one line per version with its language or region code. The tool writes the tags for the head, the HTTP Link headers and the XML sitemap block, and checks codes, duplicates and return links. Nothing is sent, everything runs in your browser.

One version per line: the code, a semicolon (or a tab, a comma, an arrow), then the full address. An empty line separates two groups of equivalent pages. You can enter x-default yourself.

Leave empty to use the first line of each group. No effect if the group already has an x-default line.

How to use the tool

Write one line per version of the same page: the language code (en, fr, fr-BE...), a separator, then the full address of that version. Separate groups of equivalent pages with an empty line: a product page and its translations form one group, the “about” page and its translations form another. Click “Generate the tags” to see the findings, then three outputs to copy or download.

The “Load an example” button fills two groups of four and three versions, with an x-default tag, so you can see the result. Each group produces a single block: the same one must appear on every page of the group, including on each version for itself.1

What the tool writes

Google accepts three locations and treats them the same way: the HTML head, the HTTP headers and the XML sitemap. There is no benefit in combining them and upkeep gets heavier: choose one.1 The tool writes all three so you can keep the one that suits your site.

The head tags are link elements, one per version. Headers mostly serve files that have no head, such as PDFs: the address sits between angle brackets and the items are separated by a comma.1 In the sitemap, each page is a url entry with its loc and one xhtml:link element per version, which needs the xhtml namespace.1 Special characters in addresses (&, for example) are escaped for HTML and XML.

<link rel="alternate" hreflang="en" href="https://www.example.com/shoes/" />
<link rel="alternate" hreflang="fr" href="https://www.example.com/fr/chaussures/" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/shoes/" />

Link: <https://www.example.com/guide.pdf>; rel="alternate"; hreflang="en",
      <https://www.example.com/fr/guide.pdf>; rel="alternate"; hreflang="fr"

What the tool checks

Google requires that each version cites itself and all the others. If page X points to Y, Y must point to X, otherwise the annotations may be ignored.1 The tool builds each block from the whole group, so return links are reciprocal by construction, and the green finding reminds you of it. It does refuse to put the same address in two groups, because the page would receive two different blocks.

It then checks the addresses: they must be complete, with the protocol, and an address like /page or //host/page will not do.1 It also rejects addresses with a space, a quote, an angle bracket or a fragment, which would break a tag or a header. One code can point to a single address per group: the first line is kept, the next one is flagged. An exact duplicate line is merged, and a group with a single version is ignored.

Language and region codes

The code starts with an ISO 639-1 language, optionally followed by an ISO 15924 script (zh-Hant) and an ISO 3166-1 alpha 2 region (en-GB). Case does not matter to Google, but the region is written in capitals by convention: the tool rewrites fr-be as fr-BE.1

Several frequent mistakes are caught. A country code alone does not name a language: “be” means Belarusian, and for Belgium you must write nl-BE, fr-BE or de-BE. Codes such as es-419 are rejected, and reserved codes such as UK or EU are ignored.1 An underscore (fr_FR) is not valid either. The validation uses the same method as the hreflang checker, based on the browser’s language and country data.

The x-default value

x-default is a reserved value: it names the fallback page when no language or region matches the visitor’s browser. Google suggests it, notably for a language or country selector, or for a home page that redirects by language. It is not mandatory.1

Tick the option and the tool adds the line to each group. By default it reuses the first version of the group; enter a code (en, for example) to pick another one. If your fallback is a separate page, a language selector for instance, enter it as an x-default line: it receives its own block in the sitemap.

The limits of the tool

The tool visits no page: it formats what you enter. It cannot know whether the addresses respond, whether a redirect moves them or whether their canonical tag points elsewhere. Google also states that versions where only the template is translated, with an unchanged main content, may be seen as duplicates.1

The same address under two codes (en and en-GB, for example) is flagged, as Google’s documentation does not cover that case. The generated sitemap may only contain addresses in the folder where it is hosted, or in its subfolders.1

After generating

Once the tags are in place, run a page through the hreflang checker: it reads the alternatives online and checks their return codes and canonicals. If you chose the sitemap, the XML sitemap validator checks the file. To decide the architecture before tagging, the SEO consultant can support you.

Frequently asked questions

Which placement should I choose: head, headers or sitemap?

Google treats all three the same way. There is no benefit in combining them and upkeep gets heavier: keep only one.1

Do I need an x-default tag?

Google suggests it, for example for a language or country selector, without requiring it.1

Must a page list itself?

Yes. Each version lists all the versions, its own included, and two pages must point to each other, otherwise the annotations may be ignored.1

Can I write “be” for Belgium or “es-419”?

No. A country code alone is not a language and “be” is Belarusian: use fr-BE, nl-BE or de-BE. The es-419 code is rejected.1

Can the versions be on different domains?

Yes, variants can live on different domains. In a sitemap, however, only addresses in the folder where it is hosted and its subfolders are allowed.1

Sources

The passages of this page and the tool’s checks refer to this reference, read on October 18, 2026.

  1. Google, “Tell Google about localized versions of your page”, Google Search Central, updated September 24, 2026. developers.google.com ↑

A multilingual site to get in shape?

hreflang annotations, canonicals and the structure of language versions are part of the SEO support I offer. I reply within 24 business hours.

Contact me