Hreflang Tag Generator
Generate correct hreflang link tags (plus x-default) for multilingual pages from a simple language/URL list.
What the generator writes from your list
Type one version of the page per line: a language code, a space, then the full URL of that version. The generator turns each line into a link rel="alternate" tag and then adds one more, x-default, pointing at the URL on your first line. The starting list gives:
Because x-default always copies the first line, put the version you want as the fallback for everyone else at the top. That is usually your main-language page or a page that lets visitors pick a language. If you'd rather not have an x-default, delete that line after copying.
Lines with only one item, such as a code with no URL, are skipped without a warning, so count the tags in the output against the versions you have.
Writing the language and region codes
The generator doesn't check codes; it copies whatever you type. Get them right yourself:
- Language first, as two letters:
en,es,de,hi. - Region optional, after a hyphen, as a country code:
en-gbfor English in the United Kingdom,es-mxfor Spanish in Mexico,fr-cafor French in Canada. - The UK is
gb, notuk.en-ukisn't a valid code, so search engines ignore a tag that uses it. - A region can't stand alone.
gboruson its own isn't a valid value; it needs a language in front, as inen-us.
Only add a region when you really have separate versions for it. If one English page serves everyone, en is enough.
The same block goes on every version
Hreflang works in both directions. If the English page lists the Spanish one as an alternate, the Spanish page has to list the English one too, or the pair can be ignored. Each page should also list itself.
The simplest way to get this right is to paste the identical block into the <head> of every version. The output already includes every version and the x-default, so one block covers them all.
Keep canonical tags consistent with it. Each language version's canonical should point to that same version, not to the English page. A Spanish page whose canonical points at the English URL is telling search engines it's a copy, which contradicts the hreflang tags.
Problems the generator won't catch
- Spaces inside a URL. Each line is split at spaces and only the first two pieces are used, so
en https://example.com/my pageproduces a tag pointing athttps://example.com/my. Encode spaces as%20, or better, use URLs without them. - URLs that redirect or don't load. Every URL should return the page itself. A tag pointing at an address that redirects, returns an error or carries
noindexis wasted. - Relative paths. Use full addresses with
https://and the domain, not/es/. - A version you forgot. If you add a fourth language later, every existing page needs the updated block, not just the new one.
Frequently asked questions
Does hreflang redirect visitors to their language?+
No. It only tells search engines which version to show in results for each language or region. Visitors who arrive at the wrong version stay there unless your site offers a language switcher.
Can I list hreflang in my sitemap instead of the page head?+
Yes. Google accepts hreflang in the HTML head, in HTTP headers or in an XML sitemap. Pick one method and use it consistently. The tags from this generator are for the HTML head.
Can I separate the code and URL with a tab instead of a space?+
Yes. Any run of spaces or tabs works as the separator, so you can paste two columns straight from a spreadsheet.
Embed this tool on your website
Free to use on blogs, school sites and intranets. Paste this code into your page's HTML; please keep the credit line.
<iframe src="https://utilityapp.lat/embed/seo/hreflang-tag-generator" title="Hreflang Tag Generator" width="100%" height="600" style="border:0;max-width:760px" loading="lazy"></iframe> <p style="font-size:13px"><a href="https://utilityapp.lat/seo/hreflang-tag-generator">Hreflang Tag Generator</a> by UtilityApp</p>