Free Hreflang Tag Generator (HTML, XML Sitemap and HTTP Header)

Hreflang tags tell Google which language or country version of a page to show each searcher. If you have the same page in English for the USA, English for the UK and Hindi for India, hreflang links them so the right version appears in each market.

Updated 6 min read

Hreflang tag generator

Use the free generator below to build correct hreflang tags in three formats, with built-in checks for the most common mistakes, such as “en-UK” instead of en-GB, relative URLs and duplicate codes. Everything runs in your browser; nothing is sent to us.

Your hreflang code will appear here.

    Put the same full set of tags on every version listed, including the page itself. That is how Google confirms the pages belong together.

    How to use the hreflang generator

    1. Add each version of the page. Enter the full URL, then pick its language and, if the page targets one country, the country.
    2. Add an x-default URL. This is the page for everyone else, usually your main page or a language picker.
    3. Click Generate. Fix anything the checks flag in red.
    4. 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.
    5. 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.

    Three ways to add hreflang tags
    MethodWhere it goesBest for
    HTML link tagsIn the head of each pageMost websites, especially with a plugin or theme that edits the head
    XML sitemapIn your sitemap file, under each URLLarge sites, or when editing page templates is hard
    HTTP headerIn the server responsePDFs 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.

    Sample before you sign

    Expanding to new countries? Get a free international SEO check.

    Send us your site and the markets you are targeting. We will check your hreflang, canonicals and regional pages and reply within one working day. No cost, no obligation.

    Fields marked * are required. We reply within one working day and your details stay private.

    Scroll to Top