By Updated

Hreflang Generator

Generate hreflang link tags and XML sitemap fragments for international sites, with BCP 47 validation, x-default support, and reciprocity checks.

Interactive tool

2 locales

Locales and URLs

HTML <link> tags

Live

Same block goes into every locale variant. Google requires reciprocal hreflang.

Sitemap fragment

XML

What is the Hreflang Generator?

A free hreflang tag builder for international websites. Add each locale and its URL, optionally set an x-default fallback, and the tool produces a ready-to-paste block of <link rel="alternate"> tags for your <head>, plus an equivalent XML sitemap fragment in case you prefer to declare alternates that way. BCP 47 validation, duplicate detection, and reciprocity hints are baked in.

How to Use the Hreflang Generator

  1. 1Add a row for each locale (BCP 47 tag like en, en-US, zh-Hant-HK)
  2. 2Paste the absolute URL for each version
  3. 3Optionally set an x-default fallback URL
  4. 4Copy the HTML block into the <head> of every locale-version page
  5. 5Or copy the XML sitemap fragment if you prefer sitemap-based alternates
  6. 6After deploying, verify in Google Search Console > International Targeting
What you get

Key features

BCP 47 validation

Catches malformed tags like "english", "EN_US", or "fr-fra" before they go live

x-default support

Dedicated field for the fallback URL Google uses when no listed locale matches the user

Duplicate detection

Flags repeated locales (case-insensitive) before they trigger Google warnings

Reciprocity-ready

The HTML output is the same block for every page version: paste it once, get bidirectional alternates automatically

XML sitemap fragment

Drop-in <urlset> with <xhtml:link> alternates if you prefer sitemap-declared hreflang

Auto-normalization

Lowercases language subtags, uppercases regions, and title-cases scripts to match BCP 47 conventions

Nothing leaves your device

The entire generator runs in your browser: your URLs never leave your device

Why Hreflang?

The hreflang attribute tells search engines that two URLs are language or region variants of the same page. Without it, Google may serve the English version to French users (or vice versa), or worse, treat your translations as duplicate content. Hreflang is the only reliable way to signal "this page exists in 12 languages: show the right one to each user." Google supports it across Search; Yandex and Baidu also honor it. Bing has its own opinion (uses content-language) but reads hreflang too.

Common use cases

  • E-commerce sites with localized product pages
  • SaaS landing pages with regional pricing
  • Multi-region marketing sites (US/UK/EU)
  • Content sites with translated articles
  • News publishers with region-specific editions
  • Documentation localized into multiple languages

BCP 47 cheat sheet

  • Language only: en, fr, de, es, ja
  • Language-Region: en-US, en-GB, pt-BR, pt-PT, es-MX, es-419
  • Language-Script: zh-Hans (Simplified Chinese), zh-Hant (Traditional)
  • Language-Script-Region: zh-Hant-HK, zh-Hans-CN
  • Special: x-default (fallback when no other locale matches)

Reciprocity is non-negotiable

If page A claims to have a French alternate at page B, page B must also claim to have an English alternate at page A. Google will silently drop one-way hreflang. The HTML block this tool produces is the same for every page in the cluster: paste it everywhere and reciprocity is automatic.

Tags vs sitemap, which to use?

Both work. <link> tags in <head> are easier to debug and review; sitemap-based hreflang scales better when you have thousands of URLs (one place to update, no per-page change). Pick one and stick with it: using both is allowed but harder to keep consistent.

Common mistakes this tool catches

  • Using underscores ("en_US") instead of hyphens ("en-US")
  • Country names instead of region codes ("USA" vs "US")
  • Missing x-default for international sites
  • Duplicate locales pointing to different URLs
  • Mixing http:// and https:// (must match the canonical scheme)
Pro tips

Tips & best practices

Always use absolute URLs

Hreflang URLs must be absolute (https://example.com/fr/). Relative paths are silently ignored by Google.

Match canonical and hreflang

The href of each hreflang tag should equal the canonical URL of that page. Mismatches confuse the crawler.

Self-referencing is required

Every page must include a hreflang tag pointing to itself. Forgetting this is the #1 cause of hreflang warnings in Search Console.

Use x-default for the global homepage

If you have a language-picker landing page, set it as x-default. Otherwise use the most-international version (typically the English one).

Avoid mixing tag-based and sitemap-based

Pick one declaration method. Mixing them is allowed but makes audits painful: Search Console reports them separately.

Built for trust

Privacy & security

The Hreflang Generator runs entirely in your browser. No URLs, locales, or generated output are sent anywhere. Close the tab and your work is gone. There is no save state on a server.

Frequently Asked Questions

What is hreflang?

Hreflang is an HTML attribute that tells search engines that two URLs are language or region variants of the same page. It prevents Google from serving the wrong locale to users and stops translations from being treated as duplicate content.

What is BCP 47?

BCP 47 is the IETF standard for language tags. Hreflang values must conform to it: language only ("en"), language-region ("en-US"), language-script ("zh-Hant"), or language-script-region ("zh-Hant-HK"). Country names like "USA" or underscored values like "en_US" are not valid.

Should I use HTML tags or sitemap-based hreflang?

Both are supported. HTML tags in <head> are easier to debug page-by-page; sitemap-based hreflang scales better for thousands of URLs because it lives in one file. Pick one method and stick with it: mixing them is allowed but harder to maintain.

Why is x-default recommended?

x-default tells search engines which URL to show when none of your listed locales matches the user (e.g. someone browsing in Swahili when you only have English, French, and Spanish). It is the safety net for international sites.

Does each page need to include all alternates?

Yes. Hreflang must be reciprocal: every locale page must reference every other locale page (and itself). The HTML block this tool generates is the same for every variant, so paste it once into every page and reciprocity is automatic.

Is my data sent anywhere?

No. The Hreflang Generator runs entirely in your browser. URLs, locales, and the generated output never leave your device.