Hreflang Tag Generator
List each language or regional version of a page, add an x-default fallback, and get validated hreflang code as HTML link tags, XML sitemap entries or HTTP Link headers. Everything runs in your browser.
How to use the Hreflang Tag Generator
- Enter each version of the page: its full URL, the language and, if it targets one country, the region.
- Add more rows with + Add language version, or press Paste a list to import lines such as
de-at https://example.com/at/. - Set x-default to the page for everyone else, such as your main site or a language picker.
- Fix any red messages in the checks panel (duplicates, relative URLs) and read the tips.
- Choose the output (HTML tags, XML sitemap or HTTP header) and press Copy code. Put the same set on every page in the group.
Example: one page in four versions
A store has English pages for the United States and the United Kingdom, a German page and a page for everyone else. Every one of the four pages carries the same block in its <head>:
<link rel="alternate" hreflang="en-US" href="https://shop.example/us/">
<link rel="alternate" hreflang="en-GB" href="https://shop.example/uk/">
<link rel="alternate" hreflang="de" href="https://shop.example/de/">
<link rel="alternate" hreflang="x-default" href="https://shop.example/">
A user searching in German from Austria gets the de page, a user in the UK gets en-GB, and a user in France, who matches nothing, gets the x-default page.
Common hreflang mistakes
| Mistake | Correct |
|---|---|
en-UK | en-GB: ISO 3166-1 uses GB for the United Kingdom |
US or eu on its own | A language is required (en-US); eu is the Basque language, not Europe |
jp, cn, se, dk | Country codes used as languages. Japanese is ja, Chinese zh, Swedish sv, Danish da |
en_US | Use a hyphen: en-US |
Relative URLs like /de/ | Absolute URLs including https:// and the host |
| No return links | Every page lists every version, including itself |
| Hreflang pointing to redirected, noindex or non-canonical URLs | Point only to the final, indexable, canonical URL of each version |
Choosing between language and language-region codes
Use a plain language code (es) when one version serves all speakers of that language. Add regions only when the content really differs, for example prices in another currency, different shipping, or spelling such as color and colour. If you create regional variants such as es-ES and es-MX, also consider a general es page (or mark one of them as es as well) so Spanish speakers in other countries still get a Spanish page. Make sure each version also has a self-referencing canonical tag; the meta tag generator can help with the rest of the head, and the sitemap generator builds the base sitemap.
Frequently asked questions
What is hreflang?
Hreflang is an attribute that tells search engines which language and, optionally, which country a page is written for, and where its equivalents in other languages are. Google uses it to show the right version in search results, for example the en-GB page to users in the United Kingdom and the de page to German speakers.
What format does an hreflang value use?
A language code from ISO 639-1 (two letters, such as en, de or ja), optionally followed by a hyphen and a region from ISO 3166-1 alpha-2 (such as GB, US or AT): en-GB, de-AT, es-MX. A region can never be used alone. The value is case-insensitive. A common mistake is en-UK: the correct code for the United Kingdom is GB.
What is x-default?
x-default is a special value for the page to show when no other version matches the user's language or location. It usually points to your main or international page, or to a language selection page. It is optional but recommended.
Does each page need to reference itself?
Yes. Every page in the set should list all versions, including itself, and every version must link back to the others. If page A points to page B but B does not point back to A, search engines may ignore the annotation. The easiest way is to put the identical block of tags on every page.
Should I use HTML tags, the sitemap or HTTP headers?
They are equivalent; use one method per page. HTML link tags in the <head> are the simplest for small sites. XML sitemaps keep the markup out of your pages and suit large sites. HTTP Link headers are the only option for non-HTML files such as PDFs.
Is hreflang the same as a canonical tag?
No. A canonical tag picks the preferred URL among duplicates, while hreflang links equivalent pages in different languages. Each language version should have a self-referencing canonical, not a canonical pointing to another language.