hreflang generator

Enter every version of one page once. You get the block for all of them, because a set where one page does not point back is discarded whole rather than half honoured.

hreflang only works if every version lists every version, including itself. That rule is why most implementations are being ignored, and it is why this generator gives you n blocks for n locales rather than one block to copy and edit. Copying and editing is how the fault is created.

Your language versions

One row per version of the same page. The generator emits a block for every one of them, because the rule that breaks most implementations is that each version has to list every other version and itself — including the ones added later.

The version to serve when nothing a visitor declares matches. Usually the international English page or a language selector.

Output as

Both are read the same way. Tags in the head are easier to verify on a live page; the sitemap form keeps the whole set in one file, which is worth it past about five locales because that is one place to be wrong instead of five.

link tags 1 line · 44 bytes
<!-- Add at least two locales with URLs. -->

Point every alternate at a URL that returns 200 and canonicalises to itself. An alternate pointing at a page that canonicalises somewhere else hands a search engine two contradictory instructions about the same document, and it resolves that by ignoring both.

The four things that break an hreflang set

In descending order of how often we see them.

One version does not point back

The English page lists English and German; the German page lists only itself. That is not a partial implementation, it is an ignored one — a set that does not agree with itself is discarded rather than honoured for the half that was right. The usual cause is two locales rendered by two templates, one of which was updated.

The code is not a valid code

gb is a region, not a language. en-gb has the region in the wrong case. uk is Ukrainian rather than the United Kingdom, which is the one that surprises people. Language lowercase, optional region uppercase after a hyphen, and nothing else parses.

The alternate canonicalises somewhere else

An alternate URL whose page carries a canonical pointing at a different URL hands a search engine two contradictory instructions about one document. Point alternates at URLs that return 200 and canonicalise to themselves. Thecanonical checker settles that in one request.

Relative URLs

hreflang values have to be absolute, including the scheme. A relative href is not resolved against the page and is simply dropped, which produces the most confusing version of this failure: markup that is present, well formed, and doing nothing.

What hreflang is not for

It does not make a page rank. It resolves which of several near-identical pages suits which audience, which matters commercially rather than positionally: the cost of getting it wrong is showing somebody the wrong currency and the wrong shipping promise at the moment they were ready to buy.

It also does not substitute for the lang attribute on the html element. That one is the baseline every page needs regardless of how many languages you publish, and it is read by things that have nothing to do with search — screen readers choosing a voice, browsers offering a translation. Thehreflang checker reads both on a live URL, and its honest limitation is the reason this page exists: from one URL it can see what that page declares and it cannot verify that the other pages agree.

Finally, it is late work. A page a crawler cannot reach does not benefit from a correct alternate set, and international rollouts routinely arrive before the fundamentals do. The technical SEO checklist puts this in the order things actually fail.

Questions people ask

What is hreflang?

A link element declaring that another language or country version of the same page exists, and where it is. It does not decide which version ranks; it tells a search engine which of several near-identical pages to serve to which audience, so your German page stops competing with your English one for the same customer.

Why is my hreflang being ignored?

Almost always because the return links are missing. Every version must point back at every other version, including itself. A set whose members disagree is discarded whole rather than partially honoured, so one template that was never updated disables the implementation for every page in the set — including the pages that were done correctly.

Do I need hreflang for a single language site?

No. Declaring lang on the html element is enough, and it is worth doing: screen readers use it to choose a voice and browsers use it to offer translation. Adding hreflang with nothing to alternate between creates work and a permanent source of errors with no upside at all.

What is x-default for?

The version to serve when nothing a visitor declares matches any of your locales. Usually the international English page or a language selector. It is optional, and the difference it makes is between a sensible fallback and an arbitrary one.

Head tags or XML sitemap?

Both are read the same way, so pick on maintenance. Tags in the head are easier to verify on a live page because you can view source and see them. The sitemap form keeps the whole set in one generated file, which is worth it past about five locales: one place to be wrong instead of five.

What format do the codes take?

Language in ISO 639-1 lowercase, and an optional region in ISO 3166-1 alpha-2 uppercase after a hyphen: en, en-GB, pt-BR. A region on its own is never valid, which is the most common malformed value there is — gb is not a language and will be dropped silently.

Should alternates point at canonical URLs?

Yes, and this catches people. An alternate pointing at a URL that canonicalises somewhere else gives a search engine two contradictory instructions about the same document: this is the German version, and also this is not the real URL. It resolves that by ignoring both.

Check the set you just wrote
against your live pages

Free account, no card. Paste your URL and get a real, scored report of your AI and search visibility.

Measuring rankings in