Hreflang tag generator
TechnicalGenerate a full set of hreflang link tags for your language and region versions, with an x-default and warnings for invalid codes. Free, no signup, and it runs entirely in your browser.
Place the same full set on every listed page, including a tag pointing to itself. That reciprocity is what makes hreflang work.
How to use it
- Enter a language-region code and URL for each version, using Add a language version for more.
- Add an optional x-default URL for visitors who match none of the versions.
- Fix any warnings, then copy the tags into the head of every listed page.
What hreflang does
Hreflang tells search engines that several URLs are versions of the same page for different languages or regions. When it works, Google can show the Spanish page to Spanish speakers and the UK page to searchers in the United Kingdom, instead of guessing. It does not boost rankings on its own and it is not a duplicate content fix; it is a signal about which version to show to whom.
You only need hreflang if you have real alternate versions: translated pages, or same-language pages that differ by country, such as US and UK pricing. A single-language site serving one market does not need it.
Getting the codes right
Each tag uses a language code, optionally followed by a region. The language is a two-letter ISO 639-1 code like en, es or de. The region is a two-letter ISO 3166-1 country code like us, gb or mx. You can use a language on its own, such as es for all Spanish speakers, but you cannot use a region on its own.
The most common error is en-uk. In ISO 3166-1, UK is not a valid code for the United Kingdom, which is gb, and uk on its own is the language code for Ukrainian. The tool flags this and other mistakes, including unknown language codes and the same code listed twice. For Chinese, script subtags like zh-hans and zh-hant are accepted.
Reciprocity and x-default
Hreflang only works when it is reciprocal. If the US page points to the UK page, the UK page must point back to the US page. Every version should carry the same full set of tags, including one pointing to itself. Missing return tags are the main reason hreflang gets ignored, which is why this tool produces one block to paste on every listed page.
The x-default value names the page for everyone who does not match a listed version. It is often a language selector or your main international page. It is optional but useful.
Implementation checks
Use absolute URLs with the protocol, and make sure each one returns a 200 status and is the canonical version of itself. Pointing hreflang at a URL that redirects, is noindexed or canonicalizes elsewhere sends conflicting signals. Hreflang can also be placed in an XML sitemap or HTTP headers; pick one method and stay consistent. If you are building sitemaps for each version, the XML sitemap generator can help.
For larger multi-country setups, hreflang errors are easy to miss at scale and worth checking in a technical SEO audit.
Questions, answered
Should I use en-uk or en-gb for the United Kingdom?
Use en-gb. Hreflang regions use ISO 3166-1 country codes, and the code for the United Kingdom is GB. UK is not a valid country code, and uk alone is the language code for Ukrainian. Tags with en-uk are likely to be ignored, so fix them anywhere they appear on your site.
Does every page need a tag pointing to itself?
Yes. Each version should include the complete set of hreflang tags, with one tag referencing its own URL. Google expects the annotations to be reciprocal across all versions. The simplest approach is to paste the identical block of tags this tool generates into the head of every page in the set.
What should the x-default URL be?
Point x-default at the page that best serves visitors who do not match any listed language or region. Common choices are a language or country selector page, or your main English page if that is what most international visitors use. It is optional, but it removes guesswork for unmatched users.
Is hreflang a replacement for canonical tags?
No, the two work together. Each language or regional version should have a self-referencing canonical and the full hreflang set. Do not canonicalize all versions to one master page, because that tells search engines the alternates should not be indexed, which cancels out the hreflang annotations.
Find out what is holding your rankings back
Send us your site. Within 2 business days you get a written audit, an AI visibility check and a short fix list ranked by impact. Free, with no contract attached.