Hreflang Tag Generator

List each language or regional version of a page with its URL — or enter a base URL and let the pattern fill them in — then press Generate tags. Switch between HTML, HTTP header, and sitemap formats.

Presets
Language versions
Import existing tags

About this hreflang tag generator

Hreflang annotations tell Google and other search engines which language and regional versions of a page exist, so each searcher sees the right one: the German page in Germany, the Mexican Spanish page in Mexico. Every version must list all the others and itself, codes must use ISO 639-1 languages and ISO 3166-1 regions, and URLs must be absolute. This generator writes the full set in any of the three supported forms — link tags for the HTML head, a Link header for PDFs and other non-HTML files, or xhtml:link entries for an XML sitemap — and checks for the common mistakes: invented codes such as jp or en-UK, duplicates, http URLs, and a missing x-default fallback.

How to generate hreflang tags

  1. List the versions. Add each language code with its URL, import existing tags, or press a preset and enter a base URL so the URLs follow your subdirectory or subdomain pattern.
  2. Press Generate tags. Read the warnings and fix any code or URL problems they point out.
  3. Choose a format and install. Copy the HTML tags into the head of every version, or use the HTTP header or sitemap format, and keep the set identical on all pages.

Frequently asked questions

What is x-default?

It names the page to show when no listed language or region matches the visitor, typically a language selector or your main English page.

Is it en-UK or en-GB?

en-GB. Regions use ISO 3166-1 country codes, and the United Kingdom’s code is GB. en-UK is a common mistake that search engines ignore.

Does every page need to link to itself?

Yes. Each version should list every version including itself, and the links must be reciprocal; otherwise search engines may ignore the annotations.

Which format should I use?

HTML link tags are simplest for web pages. Use the HTTP header for PDFs and other files without a head, and the sitemap for large sites where editing every page is impractical. One method is enough.

Can I target a country without a language?

No. A region code must follow a language, as in es-MX. A code like MX on its own is invalid, because hreflang always starts with the language.