AnyTool
Your files never leave your device. All processing happens locally in your browser.

How do I generate hreflang tags for a multilingual or international website?

Open AnyTool’s Hreflang Tag Generator and add one row per language/region version of the page — pick an ISO 639-1 language (en, es, fr), optionally an ISO 3166-1 alpha-2 region (US, GB, DE), and paste that version’s absolute URL. Set an x-default fallback URL and the current page’s own URL, then choose a format: it instantly emits the same annotation as HTML <head> <link rel="alternate" hreflang> tags, an HTTP Link: header, or an XML-sitemap xhtml:link block — each copy-ready. A live validation panel flags invalid or three-letter language codes, invalid or region-only codes (en-UK vs en-GB), relative or missing URLs, duplicate locales, a missing self-reference and a missing x-default, and reminds you the tags must be reciprocal and use one method only. Everything runs in your browser — nothing is uploaded. Hreflang is a signal Google may ignore, not a guarantee, so verify in Google Search Console after deploying.

  • Adds a row per version: ISO 639-1 language + optional ISO 3166-1 alpha-2 region + absolute URL
  • Emits HTML head tags, an HTTP Link: header, and an XML-sitemap block — pick one, copy-ready
  • Includes a self-reference and an x-default fallback automatically
  • Validation: invalid / region-only codes, relative URLs, duplicate locales, missing self-reference / x-default
  • 100% client-side — your URLs never leave the browser; honest reciprocal / one-method / verify-in-Search-Console note

What is

Hreflang tags (rel="alternate" hreflang)

Hreflang is an annotation that tells search engines which language and regional version of a page to serve a given user. Each version is declared with a value of an ISO 639-1 language code (en, es) optionally followed by a hyphen and an ISO 3166-1 alpha-2 region code (en-US, en-GB), plus the reserved x-default for unmatched users. The same complete set — listing every version including the page itself (a self-reference) — must appear on every version (reciprocal / bidirectional return links), use absolute URLs, and be implemented one way only: HTML head <link> tags, an HTTP Link: header, or an XML-sitemap xhtml:link block.

SEO & Web

Related terms

International SEOx-defaultISO 639-1ISO 3166-1 alpha-2Canonical tagXML sitemap

Frequently Asked Questions

Yes. Every version must link to all other versions and to itself. If page A points to B but B doesn’t point back, Google ignores the whole set.

Hreflang annotations must be bidirectional. Each version must list every language/region version including itself (a self-reference), and the return link must exist both ways — if the English page points to the French one, the French page has to point back. Missing return links and a missing self-reference are two of the most common hreflang mistakes, and when they occur Google ignores the affected annotations. The generator builds the same complete set you place on every version and warns when the current page’s URL isn’t in the list.

A two-letter ISO 639-1 language code (en, es), optionally a hyphen and a two-letter ISO 3166-1 alpha-2 region code (en-US, en-GB). Language-only is fine; region-only is not.

The hreflang value is an ISO 639-1 language code, optionally followed by a hyphen and an ISO 3166-1 alpha-2 region code — for example en, en-US or en-GB. Language-only values are valid; a region without a language is not allowed. Common mistakes include three-letter codes (eng instead of en), wrong region codes (en-UK instead of en-GB), non-country regions (en-eu — the EU is not a country), and reversing the order (gb-en). Invalid codes are treated as non-functional and ignored, so the generator validates each code as you type.

x-default is the fallback shown when none of your declared languages or regions match the user — usually a language picker or your primary version.

x-default is a reserved hreflang value that tells search engines which URL to serve when no other hreflang on the page matches the user’s language or region settings. It commonly points to a language-selection page or the site’s primary/global version. It is not strictly required but is strongly recommended, so the generator includes an x-default field and warns when it’s missing.

No — pick one method. Declaring hreflang two ways on the same URL is a common error that causes inconsistent, unreliable results.

The three implementation methods — HTML <head> <link> tags, the HTTP Link: response header, and the XML-sitemap xhtml:link block — are equivalent from Google’s perspective, so you should use just one consistently across the site. The header is handy for non-HTML files such as PDFs; the sitemap keeps markup out of the page; head tags are the most common. Mixing methods on one URL leads to conflicting signals and errors. The generator outputs all three forms so you can choose, but you implement only one.

Detailed Explanation

How It Works

What the Hreflang Tag Generator Produces

The Hreflang Tag Generator turns a list of language/region versions into a correct hreflang annotation and emits it in all three Google-supported forms. For each version you pick an ISO 639-1 language (en, es, fr), optionally an ISO 3166-1 alpha-2 region (US, GB, DE), and paste that version’s absolute URL; you also set an x-default fallback URL and the current page’s own URL. A format toggle then outputs the same set as: (1) HTML <head> <link rel="alternate" hreflang="…" href="…" /> tags, (2) an HTTP Link: response header (<url>; rel="alternate"; hreflang="…"), and (3) an XML-sitemap <url> block of <xhtml:link rel="alternate" hreflang="…" href="…"/> entries. A self-reference (the current page) and an x-default fallback are appended automatically, and each form is one-click copyable. The three methods are equivalent — you ship one. Output updates live as you edit.

  • One row per version: ISO 639-1 language + optional ISO 3166-1 alpha-2 region + absolute URL
  • Emits HTML head tags, an HTTP Link: header, and an XML-sitemap xhtml:link block
  • Includes a self-reference and an x-default fallback automatically
  • Each format is copy-ready; href values are escaped for safe HTML/XML output
  • All generation is pure client-side JavaScript — no server call, no CDN, no upload
Methodology

How It Validates Hreflang

A pure engine (hreflangEngine.ts) normalizes each row and runs a validation pass that surfaces the real-world hreflang mistakes documented by Google and SEO audit tools. It flags an invalid or three-letter language code (eng instead of en) and an invalid or region-only region code, reminding that en-UK should be en-GB and that a region is never used without a language; it warns on uncommon codes not in the ISO lists; it errors on relative or missing URLs (alternates must be fully-qualified absolute URLs); it errors on a duplicate locale declared more than once; and crucially it checks the self-reference — if the current page’s own URL isn’t among the alternates it errors, because every page must list all versions including itself. It warns when no x-default is set, and always reminds you that annotations must be RECIPROCAL (the same complete set on every version, with return links both ways) and that you must use ONE method only. Findings are ordered errors → warnings → info, pinned to the offending version where relevant, ending with a confirmation when everything checks out.

  • Validates ISO 639-1 language and ISO 3166-1 alpha-2 region codes; rejects region-only values
  • Errors on relative / missing URLs and duplicate locales
  • Checks the self-reference: the current page must appear in its own alternate list
  • Warns on a missing x-default; reminds about reciprocity and one-method-only
  • Findings ordered errors → warnings → info, pinned to each version
Limitations

What Correct Hreflang Can and Cannot Do

The tool is honest that correct hreflang is a signal Google MAY ignore, not a guarantee. Hreflang tells Google which language/region version of a page to show a searcher, but only works when implemented exactly right: the tags must be reciprocal (every version links to every other version AND itself), use valid ISO 639-1 language plus optional ISO 3166-1 alpha-2 region codes, use absolute URLs, and include an x-default; and it must be implemented via one method only — head tags OR the HTTP header OR the XML sitemap, never two on the same URL. Hreflang errors are extremely common — studies have found roughly a third of international websites contain them, with missing return links and missing self-references the most frequent. A canonical tag that points away from the page can also quietly override the annotation. Because of this, even a perfect set should be deployed across every version and then verified in Google Search Console; hreflang influences which version is shown but does not by itself change rankings.

  • Hreflang is a signal Google may ignore, not a ranking guarantee
  • Requires reciprocal tags, valid ISO codes, absolute URLs and an x-default
  • Implement via one method only — never mix head tags, header and sitemap on one URL
  • Missing return links and self-references are the most common errors
  • Verify in Google Search Console after deploying to every version
Hreflang generation: in-browser (AnyTool) vs typical online generators
CapabilityAnyToolTypical online generators
ProcessingRuns entirely in your browserOften server-side
Your URLsNever uploaded, works offlineSometimes sent to a server
Output formsHTML head, HTTP header and XML sitemapOften HTML (and sometimes sitemap) only
x-default & self-referenceAdded automatically and checkedOften omitted
Code validationISO 639-1 / 3166-1, rejects region-onlyOften none
Reciprocity guidanceExplicit reminder + self-reference checkRarely mentioned
Honesty about resultsClear it’s a signal Google may ignoreOften implies guaranteed effect
Cost / signupFree, no signupOften gated or ad-heavy

AnyTool builds the hreflang annotation locally and uploads nothing. The tags must be reciprocal (every version links to every other version and itself), use valid ISO 639-1 language plus optional ISO 3166-1 alpha-2 region codes, absolute URLs and an x-default, and be implemented via one method only; hreflang is a signal Google may ignore, not a guarantee — verify in Google Search Console. Comparison as of June 2026.