Hreflang Tag Generator

How to use 3 steps
  1. List each language and region version with its URL; press + Add version for more.
  2. Set the x-default URL and choose Output as.
  3. Press Generate tags, then Copy them into every version of the page.
The fallback for visitors whose language matches none of the above. Optional but recommended.
Hreflang tags

Hreflang has to be reciprocal: every page in the set must list every other page, itself included. Output here contains the whole set, so the same block goes on every version. Language codes are ISO 639-1, region codes ISO 3166-1 Alpha-2 — en-GB, not en-UK, which is the single most common mistake.

How this tool works

Hreflang tells search engines that several URLs are the same page in different languages or for different regions, so the right version is shown to the right visitor. It does not affect ranking and it is not a translation signal — it only chooses between versions you already have.

Each row becomes one alternate link. Codes are checked against the ISO shape: a two or three letter language, an optional four letter script, and an optional two letter region or three digit code. So en, en-GB and zh-Hant-TW pass, while en_GB with an underscore and en-UK do not. Duplicate codes, and two versions pointing at the same URL, are reported rather than emitted. Output is either link tags for the head or entries for a sitemap.

Making hreflang work

  • Every version must list every version, including itself: the set has to be reciprocal. A page that names the others but is not named back by them is ignored entirely.
  • Region is not language: en-GB means English as written for Britain, not simply the British site. Where the same language serves several markets, es-MX and es-ES are the correct distinction.
  • Add an x-default: it names the version to show visitors whose language and region match none of the others, which is most of the world for most sites.
  • Choose one place and stay there: head tags, HTTP headers or the sitemap. The same set declared in two of them is a common source of conflicting annotations.

What hreflang actually solves

It tells search engines that several URLs are the same page in different languages or for different regions, so the right one is shown to the right person. It does not affect ranking directly — it affects which of your existing pages appears.

The problem it prevents is real: without it, a search engine treats near-identical pages in English and American English as duplicates competing with each other, and picks one arbitrarily. With it, they are recognised as alternates of one another.

The [msm_tool slug="hreflang-generator"] produces the tags and flags the mistakes that make them silently useless.

The tags must be reciprocal

This is the rule that catches almost everyone. Every page in the set must list every page in the set, including itself.

If your English page points at the French one but the French page does not point back, search engines ignore the annotation entirely. Not partially — entirely. A one-way hreflang is the same as no hreflang, and because nothing breaks visibly, it can sit there for a year doing nothing.

Three languages means three pages each carrying four tags: one for each language plus the x-default. Six languages means six pages carrying seven tags each. The count grows quickly and it has to be complete.

Self-referencing is not optional

Each page includes a tag pointing at itself. It looks redundant and it is required — without it the set is incomplete and the same all-or-nothing rule applies.

The codes are not what people assume

  • Language codes are ISO 639-1, two letters. en, fr, de, ur.
  • Region codes are ISO 3166-1 Alpha 2, and they are countries, not languages. en-GB is English for the United Kingdom.
  • The common error is using a language where a country belongs. en-UK is invalid — the country code is GB. So is zh-CN meaning simplified Chinese; CN is China the country, and script is expressed as zh-Hans.
  • Region alone is not valid. You cannot write hreflang="GB". Language is mandatory, region is optional.

x-default is for everyone else

It marks the page shown to users whose language and region match none of your alternates. Usually that is an international English page or a language selector.

It is optional and almost always worth having. Without it, a visitor from a country you have not covered gets whichever page the search engine guesses at.

Absolute URLs, always

Relative paths do not work in hreflang. Every URL must include the protocol and the domain, and it must be the canonical version — the exact URL you want indexed, matching what your canonical tag says.

Two things follow. An hreflang pointing at a URL that redirects is broken. An hreflang pointing at a URL whose canonical points somewhere else is also broken, because you are giving contradictory instructions.

Where to put them

Three placements are valid: in the HTML head, in HTTP headers, or in an XML sitemap.

The head is simplest for a small site. The sitemap is far better for a large one — it keeps the tags in one place, avoids adding weight to every page, and makes the reciprocity easy to verify because the whole set is visible at once. For non-HTML files such as PDFs, HTTP headers are the only option.

What to check before shipping

  1. Every page lists every alternate, including itself.
  2. Region codes are countries, and en-UK appears nowhere.
  3. Every URL is absolute, canonical, and returns 200 rather than a redirect.
  4. The language actually matches the content — a tag claiming French on an English page is worse than no tag.
  5. An x-default exists.

Frequently Asked Questions

Specific to the Hreflang Tag Generator. Broader questions about this category are answered on the category page.

No. It changes which of your URLs is shown to a given visitor. The pages compete on their own merits either way, and adding hreflang to a single-language site achieves nothing.
The fallback version, for visitors whose language and region do not match any listed alternate. A language-selection landing page or the international English version are the usual choices.
The region part uses ISO 3166-1, in which the United Kingdom is GB. UK is not a valid code there, and search engines discard the annotation rather than guessing.
Neither is preferred. Head tags are easier to inspect and to get wrong per template; the sitemap keeps the whole set in one file, which is easier to audit on a large site. Pick one.
Only if each country has its own URL. If everyone reads the same page, there is nothing to choose between and the annotation has no purpose.

Subscribe to receive notifications about new tools, features, and productivity tips.