Tools

Hreflang Generator

The tags that tell a search engine which country version of a page to show, and the code mistakes that quietly stop them working.

List your language versions and their URLs. The tags come out in three formats, with the invalid codes named rather than passed through.

Everything here is worked out in your browser. Nothing you type is sent anywhere, and there is no account to make.

The page a visitor gets when no version matches their language. Usually your main market.

Language versions

Result

Fill in the fields on the left. Nothing is generated until you do, and nothing is filled in on your behalf.

How the number is worked out

  • Every page in the set carries the same block, including a tag pointing at itself. A version that does not reference itself leaves the set unconfirmed, and an unconfirmed set can be ignored in full. The same rule is why the references have to run both ways: if page A points at B and B does not point back, Google can drop the annotation entirely rather than half of it.
  • Codes are checked against the actual standards, not just their shape. Languages come from ISO 639-1 and are two letters, regions from ISO 3166-1 and are two letters. That is why en-UK fails here: people say UK, but the country code is GB.
  • URLs are normalised before the tags are written: the scheme and domain go to lower case, tracking parameters are dropped, and a trailing slash is settled one way. Two spellings of the same page look like two pages to a crawler.
  • Duplicate language codes are reported rather than merged, because picking one silently would hide which version was dropped. The same URL under two codes is only flagged, not dropped, since one page can legitimately serve two locales.
  • Three formats come out of the same set. The head tags are the usual route; the sitemap version suits a site you would rather not edit page by page; the HTTP header exists for files with no head to write into, such as a PDF.

What comes out

You will see

  • The HTML head block, the same one for every page in the set
  • An XML sitemap version, for a site you would rather not edit page by page
  • An HTTP header version, for files with no head to write into
  • Language and region codes checked against ISO 639-1 and ISO 3166-1
  • Duplicate codes reported rather than silently merged
  • URLs normalised, so two spellings of one page stop looking like two pages

How to use it

Three steps, and the third one is the point

  1. List every version of the page

    One row per language or language and region, with the full URL of that version. Two rows is the minimum, because a set of one is not a set.

  2. Set an x-default

    The page a visitor gets when no version matches their language. Usually your main market, and leaving it out is a missed instruction rather than an error.

  3. Put the same block on every page

    Not a different block per page. The identical block, including the tag that points at the page itself, on all of them.

What hreflang tells a search engine

Hreflang says that several URLs are the same page in different languages or for different countries, and which visitor each one is for. Without it, a search engine sees near duplicate pages and picks one, which is how a British customer lands on the American store.

The mechanism is confirmation. Each page in the set names every other page, including itself, and the references have to run both ways. If page A names B and B does not name A, the annotation can be dropped entirely rather than in half.

That is why the block is identical across the set, and why the self reference is not optional padding.

The Hreflang Generator result panel, first state
Two versions and an x-default. The block is identical on every page in the set, including the tag pointing at the page itself.
The Hreflang Generator result panel, second state
The same set with en-GB changed to en-UK. The tag is well formed, so nothing else in a page would complain about it.

The codes are the part that quietly fails

Hreflang fails silently. There is no error and no warning: the tags sit in the head looking correct and the search engine ignores them. Most of the time the cause is a code that is the right shape and the wrong value.

The one people hit first is en-UK. United Kingdom is what everybody writes, and the country code is GB. The tag is well formed, so nothing complains, and the annotation does nothing. The same goes for a language code that is really a country one.

This tool checks the codes against the standards themselves rather than against a shape: languages from ISO 639-1, regions from ISO 3166-1. An invalid code is named, not passed through.

The tool

What this one does

  • Validates against the actual standards

    Two letter language from ISO 639-1, two letter region from ISO 3166-1. This is why en-UK fails here and en-GB does not.

  • Writes the self reference

    Every block includes a tag pointing at its own page. A set where one page is missing that tag counts as unconfirmed and can be ignored in full.

  • Normalises the URLs

    Scheme and domain to lower case, tracking parameters dropped, trailing slash settled one way. Two spellings of a page look like two pages to a crawler.

  • Reports duplicates instead of merging them

    Two rows with the same language code are flagged. Picking one quietly would hide which version was dropped.

  • Allows one URL under two codes

    That is legitimate: one page can serve two locales. It is flagged for a look, not removed.

  • Gives you three formats from one set

    Head tags, sitemap entries and an HTTP header, built from the same list rather than typed out three times.

Reading the result

What each line is telling you

HTML head
The usual route. Paste it into the head of every page in the set, unchanged.
XML sitemap
One url entry per version, each listing the whole set. Use it when editing every page is the harder job.
HTTP header
For files with no head, such as a PDF. Sent by the server with the response.
x-default
The fallback for a visitor no version matches. It is not a language, it is an instruction for everyone else.

A free tool answers one question.
A search audit answers the rest.

We look at your search visibility across Google and the answer engines, and tell you what is costing you orders. No charge for the first look.

In practice

What you can do with it

  • Launch a second country store correctly

    Generate the set before either version goes live, so the two pages never compete with each other for the same customer.

  • Find out why a market is not showing

    If the right page exists and the wrong one ranks, the codes are the first place to look, and en-UK is the first code to look at.

  • Move a site to a new URL structure

    Regenerate the set from the new URLs. Half updated hreflang is worse than none, because it confirms a set that no longer exists.

  • Handle a shared language across markets

    One page serving several locales is normal. Give it the codes it serves and check the flag the tool raises.

Questions

Hreflang Generator questions

Why is en-UK wrong?

Because the region part comes from ISO 3166-1, and in that standard the United Kingdom is GB. UK is what people say and it is not a valid code, so a tag written that way is well formed and ignored.

Do I need an x-default?

It is not required, and it is close to free. Without it, a visitor whose language matches nothing in your set gets whichever page the engine decides on.

Does every page need to link to itself?

Yes. A page missing its own reference leaves the set unconfirmed, and an unconfirmed set can be dropped in full rather than in part.

Can two versions share one URL?

Yes, when one page legitimately serves two locales. The tool flags it so you can check it was deliberate, and leaves it in place.

Head tags, sitemap or HTTP header?

Head tags for most sites. The sitemap version suits a large site where editing every template is the harder job. The header exists for files with no head, such as a PDF.

Is my data sent anywhere?

No. The tags are built in your browser and nothing typed here is uploaded.

The rest of the set

Fifteen more, all free, all in the browser

hreflang tells a search engine which version of a page belongs to which language and country. It creates no demand in that market. It stops the wrong page from being the one that shows up.

Where this comes up