Hreflang generator: link tags and sitemap alternates

Enter the URL of each language or regional version of a page and this hreflang generator writes the alternate link tags for your head, an optional x-default and a sitemap version with xhtml:link alternates.

  • Free
  • No sign-up
  • Runs in your browser

Processing…

Runs in your browser — nothing you enter is sent to our servers.

How to use Hreflang Generator

  1. Enter a language code (such as en, es or es-MX) and the full URL for each version of the page.
  2. Use "Add language" for more versions, and optionally add an x-default URL for visitors whose language is not listed.
  3. Check any warnings about invalid codes, relative URLs or repeated languages.
  4. Copy the <head> link tags, or switch to the sitemap tab, and add them to every language version of the page.

Features

  • Alternate link tags for the head of each page
  • Optional x-default entry
  • Sitemap output with xhtml:link alternates for every URL
  • Checks language codes such as en, es, es-MX and zh-Hans
  • Warns about relative URLs and repeated languages
  • Runs in your browser with no daily limit

Examples

InputResult
en: https://example.com/en/, es-MX: https://example.com/es-mx/, x-default: https://example.com/<link rel="alternate" hreflang="en" href="https://example.com/en/" /> <link rel="alternate" hreflang="es-MX" href="https://example.com/es-mx/" /> <link rel="alternate" hreflang="x-default" href="https://example.com/" /> — Add the same three lines to all versions.
Language code: englishWarning: "english" is not a valid language code — Use ISO language codes such as en.

Limitations

  • Hreflang is a hint, not a command: search engines may still show a different version.
  • Every version must list all versions, itself included, and each must link back; the tool writes the tags but cannot check your live pages.
  • Language codes are checked by pattern only, so a well-formed code that does not exist will not be flagged.

Learn more

If you publish the same page in several languages or for several countries, hreflang annotations help search engines understand which version suits which user. A Spanish-language searcher in Mexico, for example, can be pointed to the es-MX version while an English searcher sees the en version.

Each annotation pairs a language code, and optionally a region, with the full URL of a version. Codes use ISO 639-1 language codes, with an optional ISO 3166-1 region, like es-MX. The special value x-default names the fallback page. Annotations must be reciprocal: if page A lists page B, page B must list page A, and each page should list itself.

You can place the annotations as link tags in the head, in HTTP headers, or in an XML sitemap. Choose one method to avoid conflicts. Hreflang does not translate or rank content, and it does not replace good canonical tags. Use absolute URLs, keep the version pages truly equivalent, and check the result with the international targeting tools of the search engines you use.

Frequently asked questions

What is hreflang for?

It tells search engines which language or regional version of a page is meant for which audience, so the right version can be shown to the right user.

Do I need x-default?

It is optional. It marks a fallback page for users whose language does not match any listed version, often a language selector or your main version.

Should I use head tags or a sitemap?

Either works. Pick one method and keep it consistent. Sitemaps are easier to maintain for many pages.

Why must each page link to itself?

Each version should list the full set, including itself, so every page in the group confirms the relationship. Missing return links may cause the annotation to be ignored.

Sources

Last reviewed: September 30, 2026