How to use the hreflang generator
- Add each version of the page. Enter the full URL, then pick its language and, if the page targets one country, the country.
- Add an x-default URL. This is the page for everyone else, usually your main page or a language picker.
- Click Generate. Fix anything the checks flag in red.
- Choose a format. HTML tags go in the page’s head, the XML version goes in your sitemap and the HTTP header suits PDFs and other non-HTML files.
- Add the same set to every version. Each page must list itself and all its alternates, or Google ignores the tags.
Have many pages? Switch to Bulk paste and enter one line per version, such as en-gb, https://example.com/uk/.
What is an hreflang tag?
An hreflang tag is a line of code that points to the other language or regional versions of a page. Google uses it to show searchers the version in their language or for their country, and it treats the versions as a group rather than duplicates (Google Search Central).
A tag looks like this: <link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />
The code has two parts:
- Language: a two-letter ISO 639-1 code, such as en, hi, ar or ta. It is required.
- Country: an optional two-letter ISO 3166-1 alpha-2 code, such as US, GB, IN or AE. It always follows a language: en-IN is valid, IN on its own is not.
Three ways to add hreflang
Google accepts three methods. Pick one per page, not all three.
| Method | Where it goes | Best for |
|---|---|---|
| HTML link tags | In the head of each page | Most websites, especially with a plugin or theme that edits the head |
| XML sitemap | In your sitemap file, under each URL | Large sites, or when editing page templates is hard |
| HTTP header | In the server response | PDFs and other files that are not HTML |
On WordPress, translation plugins such as WPML and Polylang add hreflang for you. If you build regional pages by hand, add the HTML tags through your theme’s head section or a header code plugin.
Hreflang rules Google checks
- Return links: if page A lists page B, page B must list page A. Without links in both directions, the tags may be ignored.
- Self-reference: each page lists itself as well as every alternate.
- Full URLs: use absolute URLs with https://, not relative paths like /uk/.
- Valid codes: language first, then an optional country. The UK is GB.
- x-default: optional but recommended, for searchers whose language or country you have not listed.
- Indexable pages only: every URL should return a 200 status, be indexable and use itself as the canonical.
Google also notes that it does not use hreflang to detect a page’s language. It works that out from the content, so each version needs to actually be in the language you declare.
Common hreflang mistakes
- Using en-UK. The ISO code for the United Kingdom is GB, so the correct tag is en-GB.
- Missing return links. Adding tags to the English page but not to the Hindi page breaks the pair.
- Pointing to redirected or noindex pages. Tags should point to the final, indexable URL.
- Canonical conflicts. If the UK page sets the US page as its canonical, Google may drop the UK page entirely.
- Region-only codes.
hreflang="IN"is invalid. Use en-IN, hi-IN or ta-IN. - Mixing methods. Different tags in the HTML and the sitemap send conflicting signals.
Do you need hreflang?
You need hreflang only when you have two or more versions of the same page for different languages or countries. A single-language site serving one market does not need it.
It matters most for businesses selling across borders: a SaaS company with US, UK and Indian pricing pages, an exporter with English and Arabic product pages for the Gulf, or a hotel with English and Tamil pages. If you are planning an international site, our SEO services and SaaS technical SEO guide cover the wider setup. New to the basics? Start with the SEO beginner’s guide.
Hreflang generator: FAQs
Does hreflang improve rankings?
Not directly. It helps Google show the right version of a page to each searcher, which reduces duplicate-content confusion and usually improves clicks in each market.
What does x-default mean in hreflang?
x-default marks the page to show when no listed language or country matches the searcher. It is usually the main page or a language picker.
What is the correct hreflang code for UK English?
en-GB. The ISO 3166-1 code for the United Kingdom is GB, so en-UK is invalid.
Can I use hreflang for the same language in different countries?
Yes. en-US, en-GB and en-IN pages can all be linked, which helps when prices, spelling or contact details differ by country.
Do hreflang tags have to be on every page?
Only on pages that have alternate versions. Each of those pages must carry the full set of tags, including a link to itself.
Is this hreflang generator free?
Yes. It is free with no sign-up, and it runs in your browser, so the URLs you enter are not sent to us.

