Hreflang Tag Generator

Generate correct hreflang tags for every international page in seconds.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

The hreflang tag generator builds the <link rel="alternate" hreflang="..."> markup, HTTP Link headers, or XML sitemap entries your international pages need to rank correctly in each target market. Enter your locale codes and URLs, add an x-default fallback, choose your preferred implementation method, and get ready-to-paste output in seconds — without ever touching a docs page or hand-writing repetitive tag strings.

Hreflang is one of the most error-prone parts of international SEO. Google’s own data shows that misconfigured hreflang is among the top technical issues found in site audits: missing return links, wrong locale codes, mismatched URLs, and forgotten x-default entries all cause search engines to silently ignore the entire annotation cluster. This tool validates locale codes against the BCP 47 pattern, checks that URLs are absolute, and enforces the bidirectional annotation requirement, so you ship correct tags rather than silent failures.

How it works

You build a table of locale-and-URL pairs. Each row maps one BCP 47 locale code (language or language-region) to the absolute canonical URL of that page variant. The tool accepts free-text input for any code and also provides a dropdown of 70+ common locales covering Europe, the Americas, the Middle East, Africa, and Asia-Pacific.

When all entries are valid, the generator emits output in three formats:

  • HTML — one <link rel="alternate" hreflang="..." href="..."> element per locale, ready to paste into <head>. This is the most widely used method and is supported by Google and Bing.
  • HTTP Link header — a single multi-value Link: header line you add to your server’s response, following RFC 5988 format. Required for non-HTML resources like PDFs; also useful when your template layer cannot be modified.
  • XML sitemap — a <urlset> block with <xhtml:link> annotations inside each <url> element. Submit to Google Search Console or Bing Webmaster Tools when you cannot modify individual pages.

The x-default fallback entry is added to every format automatically when checked. It tells search engines which URL to serve when the visitor’s language matches none of the declared variants — usually your root English page or a language-picker page.

Worked example

Suppose you have a SaaS product with four regional landing pages:

LocaleURL
en-GBhttps://example.com/
en-UShttps://example.com/us/
fr-FRhttps://example.com/fr/
de-DEhttps://example.com/de/
x-defaulthttps://example.com/

The HTML output for the en-GB page would be:

<link rel="alternate" hreflang="en-GB" href="https://example.com/" />
<link rel="alternate" hreflang="en-US" href="https://example.com/us/" />
<link rel="alternate" hreflang="fr-FR" href="https://example.com/fr/" />
<link rel="alternate" hreflang="de-DE" href="https://example.com/de/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

This exact block must be present — with all five lines — on every variant page. The French page at /fr/ carries the same five lines; the only thing that changes between pages is the page content, not the hreflang cluster.

The bidirectional requirement

The most common hreflang mistake is adding annotations only to the “main” page and forgetting the return links. Google requires every variant to reference every other variant. If en-GB references fr-FR but fr-FR does not reference en-GB, Google treats the cluster as broken and falls back to ignoring all annotations. This tool generates the full cluster for you — paste the same block onto every variant page and the bidirectional constraint is automatically satisfied.

Formula note

There is no mathematical formula here, but there is a strict structural rule. For a site with N language variants, every page must carry exactly N hreflang <link> tags plus one optional x-default. Each tag’s href must be the canonical URL (not a redirect), must be absolute (starting with https://), and must use a valid BCP 47 locale code. The generator validates all three constraints before showing any output.

Ad placeholder (rectangle)