hreflang Tag Generator

hreflang is unforgiving about reciprocity and self-reference. This builds a set that satisfies both.

Language codes are ISO 639-1 (two letters, lowercase). Region codes are ISO 3166-1 alpha-2 (two letters, uppercase). Region is optional.

0Versions
Codes valid?
0Issues

    Generated tags

    This exact block goes on every page in the set, including each page's own entry.

    Runs in your browser. Everything you type or load here is processed locally by JavaScript on this page. Nothing is uploaded to Tooltrusty or to any third party.

    What the hreflang Tag Generator does

    hreflang tells search engines that several URLs are the same page in different languages or for different regions, so the right version is served to the right searcher rather than the versions competing with each other. It is one of the most commonly misconfigured parts of technical SEO, because the rules are strict and the failures are silent.

    Three rules govern it. Reciprocity: if page A lists page B as an alternate, page B must list page A, or the relationship is ignored. Self-reference: every page must include its own entry in the set. Completeness: every page carries the entire set, not just the others. That is why the generated block below is identical for every page — you paste the same thing everywhere.

    The code format trips people up too. The language part is ISO 639-1, two lowercase letters. The optional region is ISO 3166-1 alpha-2, two uppercase letters, and it is a country code, not a language or a bloc. The single most common error is en-UK: the country code for the United Kingdom is GB, and en-UK is invalid and silently ignored. This tool flags that specifically, along with EU, which is not a country.

    x-default is the fallback for visitors who match none of your versions. It is not required, but without it a Spanish speaker in Argentina hitting a site with only en-GB and de-DE versions has no defined destination. Point it at your language selector or your most general version.

    How to use it

    1. List every version of the page, one per line, as a language code and URL separated by a comma.
    2. Set the x-default URL — usually your most general version or a language chooser.
    3. Fix anything flagged in the issues list, particularly invalid region codes.
    4. Paste the identical generated block into the head of every page in the set, including each page's own.

    A worked example

    A shoe page in five versions produces this block, which goes on all five pages:

    <link rel="alternate" hreflang="en" href="https://example.com/shoes">
    <link rel="alternate" hreflang="en-GB" href="https://example.com/uk/shoes">
    <link rel="alternate" hreflang="en-US" href="https://example.com/us/shoes">
    <link rel="alternate" hreflang="de-DE" href="https://example.de/schuhe">
    <link rel="alternate" hreflang="fr" href="https://example.fr/chaussures">
    <link rel="alternate" hreflang="x-default" href="https://example.com/shoes">

    The pattern worth noticing is the mix of language-only and language-region codes. en catches English speakers anywhere not covered by the more specific en-GB and en-US entries; search engines prefer the most specific match. That is the right structure when you have a generic English page plus localised ones, and it means an English speaker in Australia lands on the generic version rather than on the US store.

    Frequently asked questions

    Is it en-UK or en-GB?

    en-GB. The region part uses ISO 3166-1 alpha-2 country codes, where the United Kingdom is GB. en-UK is invalid and ignored entirely — a silent failure, which is why it survives so long on so many sites.

    Do I need hreflang for a site in one language?

    No. It only applies when the same content exists in multiple language or regional versions. A single-language site gains nothing from it.

    Where should the tags go — head, sitemap, or headers?

    Any of the three, but pick one and be consistent. HTML head tags are simplest for small sites. An XML sitemap is far easier to maintain at scale, since the whole set lives in one file. HTTP headers are the only option for non-HTML files such as PDFs.

    What happens if the tags are not reciprocal?

    The relationship is ignored. If page A points at page B but B does not point back, search engines treat the claim as unverified and drop it. Reciprocity failures are the single most common reason a correct-looking hreflang setup has no effect.