Free · No signup · Runs in your browser

Hreflang tag generator

Generate valid hreflang annotations for multilingual and multi-region sites, as HTML tags, sitemap entries or HTTP headers, with checks for the errors that make Google ignore them.

    01 How to use it

    4 steps, no signup

    1. 01

      List every version

      Add one row per language or country version of the page: the language, an optional region, and its URL.

    2. 02

      Set the fallback

      Optionally add an x-default URL for visitors whose language you don't target, often a language picker or your main version.

    3. 03

      Fix any warnings

      Languages and regions are picked from lists, so invalid codes like en-UK can't slip in. Duplicate codes, shared URLs, relative URLs and mixed protocols are flagged as you type.

    4. 04

      Copy the format you need

      HTML <link> tags for the page head, XML sitemap entries, or HTTP headers for PDFs and other non-HTML files.

    Short answer: add one row per language or country version of a page, pick the language and optional region from the lists, paste each URL, and copy the output. You get the full, reciprocal set of hreflang annotations as HTML <link> tags, sitemap entries or an HTTP header. Paste the same set on every version.

    What this hreflang generator does

    If your site has the same page in several languages, or versions for different countries, hreflang tells Google which one to show each searcher. Without it, a German searcher may land on your English page, or Google may treat your UK and US pages as duplicates. The hreflang tag generator builds the full, reciprocal set of annotations for a page and checks the codes as you type.

    The three ways to add hreflang

    MethodWhereBest for
    HTML tags<link rel="alternate" hreflang="…" href="…"> in each page's <head>Most sites; easy to template in a CMS
    XML sitemap<xhtml:link> under each <url>Large sites; keeps page HTML light
    HTTP headerLink: <url>; rel="alternate"; hreflang="…"PDFs and other non-HTML files

    Google documents all three as equivalent (Google Search Central). Use one method per page; mixing them makes errors harder to find.

    Rules that make hreflang work

    1. Every version lists every version, including itself. The generator outputs the full set; paste the same block on each version.
    2. Return links are required. If A references B, B must reference A.
    3. Language codes are ISO 639-1 (en, de, pt). Optional region codes are ISO 3166-1 alpha-2 (GB, US, BR).
    4. Absolute URLs only, with the protocol.
    5. Each version canonicalises to itself.

    The most common hreflang mistakes

    MistakeFix
    en-UKen-GB
    Region only: hreflang="DE"Add a language: de-DE or just de
    Region before language: US-enen-US
    Underscore: en_USHyphen: en-US
    Relative URLsFull https:// URLs
    Missing return linksPut the full set on every version
    All canonicals pointing to the English pageSelf-referencing canonicals

    Worked example

    The tool opens with three versions filled in: English at https://example.com/, German at /de/ and Mexican Spanish at /es-mx/. Add https://example.com/ as the x-default and the HTML output is:

    <link rel="alternate" hreflang="en" href="https://example.com/" />
    <link rel="alternate" hreflang="de" href="https://example.com/de/" />
    <link rel="alternate" hreflang="es-MX" href="https://example.com/es-mx/" />
    <link rel="alternate" hreflang="x-default" href="https://example.com/" />

    One warning stays: Spanish is targeted only with a region, so Spanish speakers outside Mexico have no match. Add a plain es row (or accept that they'll get the x-default) and the warning clears. Those four or five lines go into the <head> of all three pages, unchanged.

    Language vs. region targeting

    Target a language (es) when one version serves all speakers. Add a region (es-MX, es-ES) only when versions differ by country: prices, spelling, legal text. A good pattern is regional versions plus a generic language fallback: es-MX, es-ES and es for every other Spanish speaker.

    What it doesn't do

    • It doesn't crawl your site. It can't confirm the URLs load, return 200, or carry the matching tags. Check that in Search Console or a crawler after you deploy.
    • It builds the set for one page at a time. For a whole site, template the same logic in your CMS or generate the sitemap from your database.
    • The language list covers 35 common languages and 49 regions. For anything else, or a script subtag like zh-Hant, edit the output by hand.
    • In the sitemap format, the x-default URL is listed as an alternate but doesn't get its own <url> block. If your x-default is a separate page (a language picker, say), add a <url> entry for it with the same set.

    What the warnings mean

    • "… is listed twice." Two rows have the same language-region code. Google can't pick between them; keep one.
    • "… is used for both …" Two codes point to the same URL. Usually a copy-paste slip. If one page really serves both, use the plain language code instead.
    • "… isn't an absolute URL." Add https:// and the domain.
    • "Some URLs use http and others https." Use the protocol your canonical tags use.
    • "No x-default." Optional. Add one if you have a sensible page for everyone else.

    Related tools

    Once the tags are live, check how each version's title and description will look in results with the SERP snippet preview. The schema generator writes JSON-LD for the same pages, the robots.txt tester confirms the language folders aren't blocked, and the llms.txt generator covers AI crawlers.

    Privacy

    Everything is generated in your browser; nothing is uploaded.

    Last checked and updated: . Everything on this page runs in your browser; nothing you enter is sent anywhere.

    FAQ

    Frequently asked questions

    What is hreflang?
    An annotation that tells Google which language or regional version of a page to show each searcher. It links equivalent pages, for example an English, a German and a Spanish version, so the right one appears in each country's results.
    Where do hreflang tags go?
    In one of three places (pick one per page): <link rel="alternate" hreflang="…"> tags in the HTML <head>, xhtml:link entries in your XML sitemap, or an HTTP Link header (useful for PDFs). Google says the three are equivalent.
    Does every page need to list itself?
    Yes. Each version should list every version, including itself. And the annotations must be reciprocal: if page A points to page B, page B must point back to A, or Google ignores the tags.
    What is x-default?
    The fallback for searchers whose language or region matches none of your versions. It usually points to a language selector or your main international page.
    Is it en-GB or en-UK?
    en-GB. Region codes are ISO 3166-1 alpha-2, and the code for the United Kingdom is GB. "en-UK" is one of the most common hreflang errors: Google notes that UK is a reserved code, so it has no effect.
    Can I use just a country code, like hreflang="de" for Germany?
    "de" means German language, anywhere. You can't target a country without a language: "DE" alone isn't valid. To target German speakers in Austria, use "de-AT".
    Do hreflang tags have to be absolute URLs?
    Yes. Use full URLs including https://. Relative URLs are a common cause of ignored annotations.
    Does hreflang work on Bing?
    Only weakly. In 2020 Bing's Fabrice Canel said hreflang is "a far weaker signal than content-language" at Bing. If Bing matters to you, add <meta http-equiv="content-language" content="de-de"> as well.
    How do I target Traditional or Simplified Chinese?
    Google accepts a script subtag (ISO 15924): zh-Hant for Traditional and zh-Hans for Simplified Chinese, or a region such as zh-TW or zh-CN. This generator offers region codes; write a script code by hand if you need one.
    Should the canonical point to the same page?
    Each language version should canonicalise to itself, not to the English version. Pointing all versions' canonicals at one page tells Google the others are duplicates and undermines hreflang.