LaunchRanked

hreflang tag generator

Add each language or regional version of a page. We check the codes and write the tags for your HTML head, sitemap or HTTP headers.

Version 1en · English
Version 2en-GB · English
Version 3de · German

Runs in your browser. Nothing is sent or stored.

Paste into <head> on every version

<link rel="alternate" hreflang="en" href="https://example.com/" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />
<link rel="alternate" hreflang="de" href="https://example.com/de/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
  • Pass4 valid annotations. Put the same set on every URL in the list.
  • InfoReciprocal links: every page in the set must list all the others and itself. If page A points to B but B doesn’t point back, Google may ignore the pair.

What hreflang does

hreflang tells search engines that several URLs are the same page in different languages or for different regions, and which is which. When a user in Germany searches, Google can then show your German page instead of the English one. It doesn’t translate anything and doesn’t boost rankings. It picks the right version among pages you already have.

How the codes work

Each value is a language code, optionally followed by a region: de, en-GB, es-MX.

  • Language: ISO 639-1, two letters. Japanese is ja, not jp; Danish is da, not dk; Swedish is sv, not se.
  • Region: ISO 3166-1 alpha-2, two letters. The United Kingdom is GB, not UK.
  • A region can’t stand alone. us on its own isn’t valid; use en-US.
  • x-default is the fallback for users who match none of your versions.

Codes are case-insensitive. We write the language in lowercase and the region in uppercase, the common convention. The generator checks every code against the full ISO lists and flags the usual mix-ups.

The rules that break most setups

  1. Reciprocal links. If the English page lists the German page, the German page must list the English page back. Missing return links are a common hreflang error, and Google may ignore annotations that aren’t confirmed.
  2. Self-reference. Every page lists itself as well as the others. Paste the same block on every version.
  3. Full URLs. Use absolute URLs with https://. Relative paths aren’t allowed.
  4. Indexable targets. Every URL should return 200, be indexable and have a self-referencing canonical. Don’t point hreflang at redirects or noindexed pages.

Three ways to add it

Choose the output format above. HTML goes in the <head> of every version. XML sitemap writes one <url> entry per version, each listing all alternates, with the xhtml namespace declared. HTTP header is for files without HTML, like PDFs. Use one method per set of pages. Check which hreflang tags a live page already has with the meta tag checker.

Questions

Is it en-uk or en-gb?

en-gb. Regions use ISO 3166-1 alpha-2 codes, and the United Kingdom's code is GB. 'UK' is not a valid region code, and 'uk' as a language code means Ukrainian.

Do I need x-default?

It's optional but recommended. x-default tells Google which URL to show users whose language or region doesn't match any of your versions. Point it at your language picker or your main international page.

Which is better: HTML tags, sitemap or HTTP headers?

Google treats all three the same. HTML link tags are easiest for a few pages. The sitemap keeps page HTML light and is easier to manage at scale. HTTP headers are for non-HTML files like PDFs. Pick one method; using several adds places for mistakes.

Does hreflang affect rankings?

Not directly. It helps Google show the right language or regional URL to each user, among pages that would rank anyway. It also helps Google understand that near-identical regional pages, like en-us and en-gb, are alternates rather than accidental duplicates.

Should each page have a canonical tag too?

Yes, and each language version's canonical should point to itself, not to the main language version. A canonical pointing elsewhere tells Google to drop the page, which contradicts the hreflang annotation.

Autopilot · early access

Want this fixed automatically?

Autopilot checks your site, publishes researched articles at a safe pace, and tracks whether ChatGPT, Perplexity, Gemini and Claude cite you. $49/mo.

Related free tools

See all free tools