Menu

Hreflang Tag Generator

Purpose: Generate hreflang link tags so Google serves the right language/region version of your page. One line per entry: lang|url.


  

Hreflang Generator: How It Works

Hreflang tells search engines that several URLs are the same content in different languages or for different regions, so each audience is shown the right version. It is conceptually simple and, in implementation, one of the most error-prone things in technical SEO.

The syntax

<link rel="alternate" hreflang="en-gb" href="https://example.com/uk/" />
<link rel="alternate" hreflang="en-us" href="https://example.com/us/" />
<link rel="alternate" hreflang="fr"    href="https://example.com/fr/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

The value is a language code, optionally followed by a region code — fr for French anywhere, fr-ca for French in Canada. Language uses ISO 639-1, region uses ISO 3166-1 Alpha 2. Region alone is invalid: there is no hreflang="ca" meaning Canada, because ca is the language code for Catalan.

The three rules that break implementations

  1. Return links are mandatory. If page A lists B as an alternate, B must list A. One-way references are ignored entirely — this is the single most common failure.
  2. Every page must include itself. A complete set lists all versions including the current one.
  3. Hreflang must agree with canonical. Each version's canonical must point to itself. A page canonicalising to a different language version cancels the hreflang.

x-default

The x-default value marks the fallback for users whose language or region matches none of your versions — typically a global homepage or a language selector. It is optional but strongly recommended, because without it those users get whichever version the engine guesses.

Where to put the tags

MethodBest forDrawback
HTML <head>Small to medium sitesEvery page carries every alternate — heavy at scale
HTTP headerPDFs and non-HTML filesHarder to inspect and debug
XML sitemapLarge sites, many languagesChanges are slower to be picked up

Use exactly one method. Implementing the same set in two places invites contradictions when one is updated and the other is not.

What hreflang does and does not do

It is a signal for which version to show, not a ranking boost. It does not consolidate ranking signals — each version competes on its own merits — and it does not prevent versions from being treated as duplicates if the content is genuinely identical. Two English pages differing only in currency symbol may still be filtered as near-duplicates regardless of correct hreflang.

Errors worth checking for

Search Console's International Targeting report surfaces missing return tags and unknown codes, and is the fastest way to find the mismatch in a large set.

Frequently Asked Questions

Does hreflang improve rankings?
No. It helps the right version of a page reach the right audience, which improves engagement and reduces the chance of the wrong version ranking in a market. Each version still competes on its own merits.
What is the most common hreflang mistake?
Missing return tags. If page A references B, B must reference A. Without the return reference the entire relationship is ignored, which means the tags do nothing at all.
Do I need x-default?
It is optional but recommended. It defines the fallback for users whose language or region matches none of your versions — usually a global page or language selector. Without it, engines guess.
Can I use a region code without a language?
No. The language code is mandatory and comes first. 'ca' means Catalan, not Canada — for Canadian English you need 'en-ca'.
Should hreflang go in the head, headers or sitemap?
Any one of the three, but only one. The head is simplest for small sites; the sitemap scales better for large multilingual sites; HTTP headers are needed for non-HTML files such as PDFs.
Do I need hreflang for two English pages targeting different countries?
Yes, using en-gb and en-us style values, so each market sees the right pricing and terminology. Be aware that if the pages are otherwise near-identical they may still be filtered as duplicates.

Related SEO Tools

Browse all SEO tools →