Hreflang Tag Generator

The right language, for the right searcher.

Add each language or country version of a page. You get the full, reciprocal set of hreflang annotations with x-default, checked for the code mistakes that make Google ignore them.

Build my hreflang tags

Free · No sign-up · HTML, sitemap or header format · Code checks built in

Hreflang Tag Generator · free, runs in your browser

Page versions

Your hreflang code

In HTML format, the same full set of tags goes in the <head> of every version listed, including a tag pointing to itself. Language codes are ISO 639-1 (en, es, de); region codes are ISO 3166-1 alpha-2 (US, GB, MX).

Hreflang without
the usual mistakes

Hreflang tells Google which version of a page to show in each language or country. It is easy to get subtly wrong, and when it is wrong Google ignores it. The generator writes the full set and checks the codes.

Reciprocal by default

Every version lists every other version and itself, which is the return-tag rule Google requires for hreflang to count.

x-default fallback

Set the page searchers see when none of your language or country versions match them.

Three output formats

HTML link tags for the head, XML sitemap entries for large sites, or an HTTP Link header for PDFs and other files.

Code checks

Flags invalid language and region codes and the classic en-UK mistake, where the correct code is en-GB.

Duplicate detection

Warns when the same language-region code points at two different URLs, which confuses search engines.

Any number of versions

Add or remove versions freely: two languages or twenty country sites.

How to use the hreflang tag generator

  1. Add a row for each version of the page: its full URL, the language code and, if it targets one country, the region code.
  2. Set an x-default URL, usually your main site or a language-selector page.
  3. Fix anything the warnings flag.
  4. Choose a format and copy the code. For HTML, add the same block to every version listed.

When you need hreflang

Hreflang is for sites that have the same content in different languages, or in the same language for different countries, such as separate US, UK and Australian pages with different prices or spelling. It helps Google show the right version to each searcher and prevents similar regional pages from being treated as duplicates competing against each other.

A single-language site with one audience does not need it.

The rules that make hreflang work

Tags must be reciprocal

If the English page points to the Spanish page, the Spanish page must point back. Google ignores annotations that are not confirmed from both sides. That is why this tool gives you one identical block for every version.

Include a self-reference

Each page lists itself as well as its alternates.

Use the right codes

Language first (ISO 639-1), then an optional region (ISO 3166-1 alpha-2): en, en-GB, es-MX. You cannot use a region on its own. The UK is GB, not UK.

Point to canonical, indexable URLs

Every URL in a hreflang set should return 200, be indexable and be its own canonical. Pointing hreflang at redirects or noindexed pages breaks the set.

Managing many language versions? The XML format fits straight into a sitemap; the XML sitemap generator can build the base file.

Frequently asked questions

What is hreflang?

Hreflang is an HTML attribute, also usable in sitemaps and HTTP headers, that tells search engines which language and optional country each version of a page is for, so they can show searchers the right one.

What does x-default mean in hreflang?

x-default marks the fallback page for searchers whose language or location does not match any of your listed versions. It is often the homepage or a language-selector page.

Is it en-UK or en-GB?

en-GB. Region codes use ISO 3166-1, where the United Kingdom is GB. The code uk is Ukrainian, so en-UK is invalid and gets ignored.

Should hreflang go in HTML or the sitemap?

Either works; use one method consistently. HTML tags suit small sites. Sitemaps are easier for large sites because the annotations live in one file instead of every page head.

More free SEO tools

Free · No sign-up

XML Sitemap Generator

Paste a list of URLs and download a valid sitemap.xml.

Free · No sign-up

Robots.txt Generator

Build robots.txt with presets for WordPress and AI crawlers.

Free · No sign-up

Meta Tag Generator

Title, description, canonical, robots and social tags as one paste-ready block.

Free · No sign-up

Schema Markup Generator

JSON-LD for Article, FAQ, Organization, LocalBusiness and Product.

Guide

GEO & AI Search guides

Our hub of guides on ranking in Google and getting cited by AI search.