Hreflang Tag Generator

100% private — runs on your device, never uploaded. Works offline once loaded.

Generate correct rel="alternate" hreflang link tags for every language and region version of your page, including the x-default fallback. Language codes are validated as you type.

What hreflang tells search engines

Hreflang annotations tell Google which language and, optionally, which regional version of a page to show a given user. If you have an English page for the US, another for the UK, and a French page for Canada, hreflang links them together as alternates so a searcher in London sees the UK page rather than the US one. Without it, Google may pick the wrong variant or treat near-duplicate translations as competing pages.

The annotation is a set of tags, one per version, each pointing at the URL for that language/region. It does not change rankings directly; it improves how the correct version is matched to the right audience, which reduces bounce and improves the experience for international visitors.

The reciprocity rule (the part people get wrong)

The single most common hreflang mistake is missing return links. Hreflang must be bidirectional: if page A lists page B as an alternate, page B must also list page A. In practice this means every page in a language group carries the same complete set of hreflang tags, including a self-referencing tag pointing at itself.

If the links are not reciprocal, Google ignores the annotation entirely. That is why this generator produces one full block you can paste onto every version: put the identical set on all pages, and the return links take care of themselves. Each page's set should include a tag for every version plus itself.

Language and region codes

Codes follow a strict format that this tool validates as you type, highlighting anything invalid in red so it never ships silently broken.

  • Language — a lowercase ISO 639-1 code such as en, fr, de, es.
  • Region (optional) — an ISO 3166-1 Alpha-2 code such as us, gb, ca, appended with a hyphen: en-us, en-gb, fr-ca.
  • x-default — a reserved value, not a real locale, that points to the fallback page for unmatched users.
  • Region alone is never valid; you cannot target a country without also naming the language.

x-default and common pitfalls

The x-default tag names the page to show when none of your specific language/region versions fit the user, for example a global homepage or a language-picker page. It is optional but strongly recommended for international sites, so this tool offers a one-click button to add it.

Beyond missing return links, watch for these traps: pointing hreflang at non-canonical or redirecting URLs, mixing hreflang with a canonical that points to a different language version, and using underscores (en_us) instead of hyphens (en-us). Always use absolute URLs, keep hreflang and canonical consistent, and validate the live pages after deployment.

Frequently asked questions

Do I really need a self-referencing hreflang tag?

Yes. Each page must include a tag pointing at itself in addition to tags for all other versions. Omitting the self-reference is a common reason Google ignores the whole annotation.

Can I put hreflang in an XML sitemap instead of the <head>?

Yes. Hreflang can be delivered via <head> link tags, HTTP headers, or xhtml:link entries in an XML sitemap. Pick one method and apply it consistently across all versions.

Is hreflang case-sensitive?

The values are treated case-insensitively, but the convention is lowercase language and region (en-us). This generator preserves what you type; just keep it consistent across pages.

What happens if I only specify a language, no region?

That is perfectly valid and common, for example hreflang="en" for all English speakers. Add a region only when you genuinely serve different content to different countries.

Why is one of my codes highlighted in red?

It does not match the expected language or language-region format, so it would be invalid to search engines. Invalid rows are also skipped in the generated output until you correct them.

Does this replace a canonical tag?

No. Hreflang and canonical serve different purposes and should coexist. Each version's canonical should point to itself, not to another language, otherwise the hreflang signals conflict.

Advertisement