Hreflang generator

List each language or region version of your page and get the full set of hreflang link tags — x-default included, codes validated, ready to paste into your head.

Hreflang tags — paste into every page's <head>
Fill in a URL and a language code to generate the tags…

Building a valid hreflang set

Add one row per language or region version of your page — the URL it lives at, plus its code. Codes are validated as you type against the format search engines expect (language or language-REGION) and normalized to the conventional casing, so EN-us comes out as en-US. Invalid codes are flagged on the row and left out of the output.

The result is one <link rel="alternate" hreflang="…" href="…" /> per version, plus an optional x-default line. Paste the identical block into the head of every version — each page must list all alternates including itself, or the annotations are ignored as non-reciprocal.

Hreflang mistakes to avoid

  • Missing return links — the most common failure. Every version must point at every other version (and itself); one page with a partial set breaks the cluster.
  • Wrong codes — uk is Ukrainian, not the United Kingdom (that's en-GB), and region-only values are invalid.
  • Pointing at redirects or noindex pages — each href should be the canonical, indexable URL of that version, returning 200.
  • Hreflang as geo-blocking — it's a hint about which version to show, not access control; all versions stay crawlable by everyone.
  • Use absolute URLs, https included — relative hrefs are ignored for hreflang.

Frequently asked questions

What are hreflang tags?

Hreflang tags are <link rel="alternate"> elements in a page's <head> that tell search engines which language and region each version of the page targets — so a searcher in Mexico gets the es-MX page and one in France gets the fr page, instead of whichever version happened to rank.

What format do hreflang language codes use?

An ISO 639-1 language code, optionally followed by an ISO 3166-1 region code: en, en-US, pt-BR, es-419 (Latin America, a UN M49 area code). Region-only values like just 'US' are invalid — the language part is required. By convention the language is lowercase and the region uppercase, which is what this generator outputs.

What is x-default for?

x-default marks the fallback URL for visitors whose language doesn't match any of your alternates — typically the homepage, a language selector, or your primary-language version. It's optional but recommended whenever you have more than a couple of languages.

Does every page need to list all alternates, including itself?

Yes. Hreflang must be reciprocal: every language version of a page carries the same complete set of tags, and that set includes a self-referencing tag for the page it's on. If page A points to page B but B doesn't point back, search engines ignore the annotation. Generate the block once and paste it into every version's <head>.

Do hreflang tags go on every page or just the homepage?

Every page that has translations — hreflang works page by page, not site by site. The /pricing page's tags point at the translated /pricing pages, not at translated homepages.

Can I use hreflang in a sitemap instead of link tags?

Yes — the same annotations can live in an XML sitemap (xhtml:link entries) or, for non-HTML files, in HTTP headers. Pick one method per page and stay consistent; the head tags this tool generates are the most common and easiest to verify.

Related free tools

See all free tools →

Built something? Put it online in seconds

host0 is the cloud for small software: bring any coding agent, build the tool only you need — like this one — and say "deploy to host0". Live at a shareable URL, no servers to run.