Hreflang Generator
Generate hreflang link tags for localized page alternates.
Overview
The Hreflang Generator builds the set of <link rel="alternate" hreflang="..."> tags that tell search engines which pages are translations or regional variants of each other. Provide a list of language-region codes and target URLs, and the tool emits one tag per locale plus the required reciprocal x-default line.
Useful for SEO managers and localisation engineers learning how to add hreflang tags for international SEO or how to set up x-default for an unspecified locale. Reach for it when launching a multi-language site, adding a new market, or fixing the hreflang errors Google Search Console surfaces.
How it works
Hreflang values follow BCP 47 language tags: a primary language subtag (en, fr, zh) optionally followed by a region subtag (en-GB, en-US, zh-Hant). Search engines require every alternate to reference every other alternate — including itself — and to include the reciprocal back-link, otherwise the cluster is invalid.
The generator validates each tag against BCP 47, enforces the mutual-link rule, and inserts a hreflang="x-default" entry for the fallback URL search engines show when no locale matches the user's preferences. Output can be HTML link tags or sitemap XML annotations.
Examples
- English (US) and English (UK) pages cross-reference each other plus an x-default to the canonical English page.
- A four-language cluster (en, fr, de, es) produces five tags per page (the four plus x-default).
- A Chinese site distinguishes
zh-Hans(simplified) fromzh-Hant(traditional) rather than the barezhtag. - Generator catches a missing reciprocal link from the French page back to the English variant.
FAQ
Should I put hreflang in HTML or the sitemap?
Either works. HTML is simpler for small sites; sitemap XML annotations scale better for thousands of URLs because they're applied in one file.
Do I need x-default?
It's optional but recommended when no locale variant fits the user — search engines display the x-default URL.
Why is Google ignoring my hreflang?
Most often because of missing reciprocal links or mistyped language codes. Every variant must reference every other variant by URL, and every URL must be a 200 status — not a redirect.
Hreflang vs lang attribute?
lang on the <html> element tells the browser the document's language (for accessibility). hreflang tells search engines which page belongs to which locale. Both should be set and they should agree.