This hreflang tag generator turns a simple list of language versions into code you can paste: link tags for the page head, one HTTP Link header, or entries for an XML sitemap. The second tab checks a live page. It reads the hreflang tags in the HTML, tests every code, looks for x-default and the self-reference, and opens each version to see whether it links back.
What hreflang does
When a page exists in more than one language, or in one language for more than one country, hreflang tells Google which version belongs to which audience. A searcher in Germany then sees the German page, and a searcher in the UK sees the British English page instead of the American one.
Hreflang does not raise rankings, and it does not stop duplicate content from being duplicate. It only helps the search engine swap in the right version. Google and Yandex document support for it. If your site has one language for one market, you do not need hreflang at all.
The codes: language first, country second
Each hreflang value is a language code, optionally followed by a country code:
- Language: two letters from ISO 639-1, such as
en,de,idorja. - Country: two letters from ISO 3166-1 alpha-2, such as
gb,us,atorbr. Written after a dash:en-gb,pt-br. - Script (rarely needed): four letters, as in
zh-hantfor Traditional Chinese. - x-default: the page for everyone who matches none of your versions, often a language chooser or your main version.
A country on its own is not valid. hreflang="de" means German anywhere; hreflang="at" means nothing.
| Wrong | Why | Right |
|---|---|---|
| en-uk | UK is not an ISO country code | en-gb |
| jp | JP is the country; the language is ja | ja or ja-jp |
| es-419 | Google does not accept UN region numbers | es, or es-mx, es-ar and so on |
| /de/ | Relative URL | https://example.com/de/ |
The generator checks every code against the names your browser knows, so a typo or a country used as a language shows up before you publish.
How to use the hreflang tag generator
- List the versions of one page. One line each: code, then the full URL. For example
en, https://example.com/andde, https://example.com/de/. - Add x-default if you have a page for everyone else.
- Read the checks. Green lines show what each code means, such as "English, United Kingdom". Red lines need a fix.
- Pick a format and copy. Then repeat for the next page: hreflang is set page by page, not once per site.

Three ways to add hreflang
Google reads hreflang in three places. Pick one method per page and stay with it, because mixing them makes mistakes hard to find.
- HTML head. The usual choice. Every version carries the same block of link tags, including a tag for itself.
- HTTP Link header. For PDF files and other documents without a head.
- XML sitemap. Good for big sites, because the page HTML stays light. Each URL gets an entry with every alternate listed below it.
The rules that break most setups
- Return tags. If the English page points to the German page, the German page must point back to the English page. Without the return tag, Google may ignore the pair. This is the most common error, and the audit tab tests it by opening every version.
- Self-reference. Each page lists itself as well as the others.
- Canonical conflicts. Each version should be its own canonical. If the German page has a canonical pointing to the English page, Google treats it as a copy and ignores its hreflang.
- Indexable pages only. A version with noindex, a redirect or a 404 cannot be shown, so its tags are wasted.
- Full URLs. Always with https:// and the domain.
Checking a live page
Switch to "Check a page", enter a URL and press Check hreflang. The tool reads the HTML the server sends, lists the tags, and reports bad codes, duplicates, a missing self-reference, a canonical that points elsewhere and noindex. Then it opens each alternate version, up to 20 pages, and checks for the return tag.
It reads HTML only. If you set hreflang in the HTTP header or the sitemap, the tool reports "no tags in the HTML", which is expected. The standard level checks one page at a time; PRO checks up to ten. Search Console no longer has its old International Targeting report, so a manual check like this, plus the URL Inspection tool, is how you confirm the setup.
Use the hreflang tag generator for each page that has translations, and run the check after every template change, because one broken return tag can undo a whole language section.
Frequently asked questions
Do I need hreflang if my site is only in English?
Usually not. You only need it when you have different versions for different languages or countries, for example separate pages for the US and the UK with different prices or spelling. One version for everyone needs no hreflang.
Is x-default required?
No, but it is useful. It tells Google which page to show when a searcher's language or country matches none of your versions. Most sites point it to the main language or to a page where visitors choose a language.
Why does Google ignore my hreflang tags?
The usual causes are missing return tags, a canonical that points to another version, wrong codes such as en-uk, relative URLs, or versions that redirect or have noindex. Run the check tab on each version to find which one breaks the set.