# Hreflang Tag Generator

> List your language versions and copy hreflang link tags, a Link header or sitemap entries, with checks for the mistakes that make Google ignore them.

- Page: https://codethatmoves.com/tools/seo/hreflang-generator/
- Site: Code That Moves
- Category: SEO and AI search
- Free, runs in the browser, nothing is uploaded
- Last checked: 2026-11-03

## What it does

- Output as HTML link tags, an HTTP Link header or XML sitemap entries with xhtml:link
- Language and region codes checked with the browser's own Intl locale data, shown by name (English (United Kingdom)), with suggestions for common codes as you type
- Catches underscores, en-UK instead of en-GB, unknown regions such as en-XX, UN M.49 areas such as es-419, three-letter languages, duplicate codes and relative URLs, and says when a code is rewritten to its standard form (iw becomes he)
- Check existing hreflang: paste the head HTML of each language version, or a sitemap with xhtml:link, and get missing self-references, missing return links, mismatched codes and canonicals pointing elsewhere, plus a matrix of who links to whom
- Reminds you about x-default and return links
- Copy or download the output, and a share link that restores the list
- URL pattern templates: subfolders (/uk/), subdomains (uk.example.com), country domains (example.de) or a query parameter (?lang=uk), applied to a list of paths
- Bulk CSV input: one row per page, one column per hreflang code
- Per-page HTML tag blocks and a full sitemap.xml with xhtml:link alternates, ready to download
- Checks across the whole set: a URL used by two pages (mismatched return links), missing versions, relative URLs, bad codes and country-domain locales with no domain set

## How to use it

1. Enter one row per language version: a code such as en, en-GB or de, and the full URL of that version.
2. Add an x-default row for the page you want people to land on when no version matches their language.
3. Pick HTML, HTTP header or sitemap, fix anything the checks flag, and copy the same set onto every version of the page.
4. To audit what a site already has, open Check existing hreflang, add each version's URL and paste its head HTML (view source, copy the head), or paste the sitemap. Fix every Fix line, then re-check.
5. For a whole site, open Many pages: pick a URL pattern and list your paths, or paste a CSV with a header row of codes and one page per row, then copy the per-page tags or download sitemap.xml.

## What it checks and why

hreflang tells Google which URLs are language or regional versions of the same page, so a searcher in Germany gets the German page and one in the UK gets the British one. Google reads it from link tags in the head, from an HTTP Link header (useful for PDFs), or from xhtml:link entries in a sitemap. Use one method; they do the same job.

The value is a language code from ISO 639-1, optionally followed by a region from ISO 3166-1 alpha-2, such as en-GB. A region on its own is not valid, so de means German everywhere, not Germany. The usual slips are en-UK (the code for the United Kingdom is GB), underscores instead of hyphens, and relative URLs.

Every version has to list all the others and itself. Google's documentation says that if page A links to page B, B must link back to A, or the annotations may be ignored. x-default marks the fallback page, often a language picker or the main version.

Google's guidance on multi-regional sites describes the common URL structures: country domains, subdomains, subdirectories and URL parameters, and advises against parameters. The pattern templates build the alternates for each of these, so a path such as /pricing becomes the full set of language URLs in one step.

In a sitemap, each language URL gets its own url entry, and every entry repeats the full list of alternates, itself included. The bulk checks look for a URL that two page rows both claim, which would give those versions different alternate lists and break the return links.

## Specs and sources

- [Google Search Central: Tell Google about localized versions of your page](https://developers.google.com/search/docs/specialty/international/localized-versions)
- [RFC 5646: Tags for Identifying Languages (BCP 47)](https://www.rfc-editor.org/rfc/rfc5646)
- [ISO 3166 country codes (ISO)](https://www.iso.org/iso-3166-country-codes.html)
- [MDN: Intl.getCanonicalLocales()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales)
- [Google Search Central: Managing multi-regional and multilingual sites](https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites)
- [sitemaps.org protocol](https://www.sitemaps.org/protocol.html)

## Limits

- Codes are checked with your browser's Intl data, so a very new or rare code may be reported differently in another browser.
- It does not fetch your pages. Return links and canonicals are checked only for the versions you paste; it cannot see whether a URL redirects or returns an error.
- The single-page sitemap output covers one set of alternates; use Many pages for a full sitemap.
- Pattern templates assume every page exists in every listed language; drop missing versions by using the CSV input with empty cells instead.
- Bulk checks only see the set you enter: they cannot tell whether a URL resolves, redirects or carries a different canonical.
- The sitemap is not split; the sitemaps protocol caps one file at 50,000 URLs and 50 MB uncompressed.

## Questions

### What is the hreflang code for the UK?

en-GB. The ISO 3166-1 code for the United Kingdom is GB, so en-UK is not a valid region and uk on its own means the Ukrainian language.

### Do I need x-default?

It is optional. Google recommends it for the page to show when no other version matches the searcher's language, such as a language picker or your main version.

### Should hreflang include the page itself?

Yes. Each version lists every version, including itself, and the set should be the same on every page.

### HTML tags or sitemap: which is better?

Google treats them the same. Tags in the head are simplest for a few versions; a sitemap keeps big sets out of every page; the HTTP header works for files that are not HTML.

### Can I use a country code without a language?

No. The first part must be a language. To target a country, add the region after the language, such as de-AT or fr-CA.

### How do I add hreflang for a whole site?

Use Many pages. Either choose your URL pattern (subfolder, subdomain, country domain or query parameter) and list the paths, or paste a CSV with one row per page and one column per language. You get tags for each page and a sitemap.xml with all alternates.

### Is es-419 a valid hreflang code?

It is a valid language tag, but Google's hreflang docs support only ISO 3166-1 alpha-2 region codes, and 419 (Latin America) is a UN M.49 area code. Use plain es, or one tag per country such as es-MX and es-AR.

### Should each hreflang page have a self-referencing canonical?

Yes. Each version in the set should be the canonical of itself. A canonical that points to another language version tells Google to index that URL instead, which works against the hreflang set.

### Do I need hreflang for the same language in different countries?

Only if the pages differ, for example prices, spelling or shipping for en-US, en-GB and en-IE. Google's docs cover this case: list each regional version with its own language-region code, plus a plain en version if you have one.

### What does a hreflang return link error mean?

Page A lists page B as an alternate, but B does not list A back, or lists a different set. Google's docs say that if two pages do not both point to each other, the tags are ignored. Paste both pages into Check existing hreflang to see which link is missing.
