ranknexusSEO, AI search & ads

Hreflang tags for every version of your page.

Enter each version of a page, with its language code, an optional region code and its full URL, and the generator writes the complete hreflang set in all three formats Google accepts: link tags for the head, an HTTP Link header and XML sitemap entries. It flags invalid codes such as en-UK, region-only codes, duplicates and relative URLs, and adds x-default when you give one.

  • Free
  • No sign-up
  • Runs in your browser

Example: a US English and a UK English version of one page, with the US page as x-default.

Version 1
Version 2

Or start from a preset

One language, two countries: en-US and en-GB. The UK's region code is GB, so en-UK does nothing in Google.

Language: two letters from ISO 639-1, such as en or de, plus a script if you need one, such as zh-Hant. Region, optional: two letters from ISO 3166-1, such as US or GB.

3 lines: 2 versions and x-default.

Code format
For the <head> of every page in the set
<link rel="alternate" hreflang="en-US" href="https://www.example.com/" />
<link rel="alternate" hreflang="en-GB" href="https://www.example.com/uk/" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/" />

Return links: put this same set, unchanged, on every page it lists. Each page must list itself and all the others, or Google ignores the pairs that don't point both ways.

Optional: add a plain en line as well. Google suggests a catchall page for speakers of a language outside the regions you list, and it can be one of the pages above.

Paste this same block on every page in the set

0 of 2 pages done

Google says the tags must sit inside a well-formed <head>, so check the rendered page if a plugin or script adds them.

Return linksAll 2 pages list all 3 codes.
Each page in the set must list every code, itself included, or Google ignores the pairs that don't point both ways.
Pageen-USen-GBx-default
en-UShttps://www.example.com/Lists en-USLists en-GBLists x-default
en-GBhttps://www.example.com/uk/Lists en-USLists en-GBLists x-default

Codes are written the usual way, with a lowercase language and an uppercase region (en-GB); Google accepts either case. Everything is built in your browser: nothing you type is sent to us, and no URL is visited.

Selling in more than one country?

We send you a recorded walkthrough within 2 business days.

Get a free international SEO reviewAsk on WhatsApp
How this is checked
  • Languages must be ISO 639-1 codes and regions ISO 3166-1 alpha-2 codes, as Google supports; scripts follow ISO 15924. UK, EU and UN aren't region codes, so en-UK is flagged with en-GB suggested.
  • Every URL must be fully qualified, with http or https. Entries with a bad code or URL are left out of the code until fixed, and said so.
  • Return links: the same set goes on every page it lists, so every page lists itself and all the others.
  • Nothing is fetched: the generator can't see whether your live pages already carry the tags.

Reviewed by M. Nouman, Co-founder, RankNexusUpdated 6 sourcesHow we work it out

The guide

Hreflang tags that Google can use, with examples.

What this tool checks

  • ISO 639-1 language and ISO 3166-1 region codes
  • en-UK, region-only and duplicate codes flagged
  • Full https URLs, never relative paths
  • x-default and the return-link rule

An hreflang example in all three formats

Take an example business with a pricing page in three versions: US English, UK English and German, with the US page as the fallback for everyone else. The same set, written three ways:

1. Link tags, in the <head> of every version (example URLs)
<link rel="alternate" hreflang="en-US" href="https://www.example.com/pricing/" />
<link rel="alternate" hreflang="en-GB" href="https://www.example.com/uk/pricing/" />
<link rel="alternate" hreflang="de-DE" href="https://www.example.com/de/preise/" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/pricing/" />
2. An HTTP Link header, sent with each version (one header, values separated by commas)
Link: <https://www.example.com/pricing/>; rel="alternate"; hreflang="en-US",
      <https://www.example.com/uk/pricing/>; rel="alternate"; hreflang="en-GB",
      <https://www.example.com/de/preise/>; rel="alternate"; hreflang="de-DE",
      <https://www.example.com/pricing/>; rel="alternate"; hreflang="x-default"
3. XML sitemap entries (one <url> per version, each listing the full set)
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://www.example.com/pricing/</loc>
    <xhtml:link rel="alternate" hreflang="en-US" href="https://www.example.com/pricing/" />
    <xhtml:link rel="alternate" hreflang="en-GB" href="https://www.example.com/uk/pricing/" />
    <xhtml:link rel="alternate" hreflang="de-DE" href="https://www.example.com/de/preise/" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://www.example.com/pricing/" />
  </url>
  <!-- Repeat the <url> block for /uk/pricing/ and /de/preise/, with the same four xhtml:link lines -->
</urlset>

Google treats the three as equivalent, so use one. Google says link tags must sit inside a well-formed head section, so check the rendered page if a plugin or script writes them. The HTTP header is what you need for a PDF, which has no head. In the sitemap, the order of the xhtml:link lines doesn't matter, but the xhtml namespace on the urlset line does.

Hreflang language and region codes

A code is a language from ISO 639-1, then, if you need it, a hyphen and a region from ISO 3166-1 alpha-2: en, en-GB, fr-CA. Google supports only those two lists, plus an optional script code for languages written in more than one script, such as zh-Hant for Traditional Chinese. Case doesn't matter. The W3C's advice is to keep the tag as short as possible and add a region only when you have different pages for different countries.

Codes that look right but aren't (checked against the IANA and Library of Congress code lists)
WrittenWhat it actually meansUse instead
en-UKUK is not a region code, so Google ignores iten-GB
ukUkrainianen-GB for British English; uk only for a Ukrainian page
gb or usA region with no language, which Google says is not validen-GB or en-US
jpNot a language code (JP is the region Japan)ja, or ja-JP
seNorthern Sami, not Swedishsv, or sv-SE
dkNot a language code (DK is the region Denmark)da, or da-DK
grNot a language code (GR is the region Greece)el, or el-GR
beBelarusian, not Belgiumnl-BE, fr-BE or de-BE
es-419Latin America as a UN region number, which Google doesn't supportes, or a code per country such as es-MX

If you have regional versions of one language, Google suggests a generic page as well: an en page for English speakers outside the countries you target, alongside en-US and en-GB.

When to use hreflang x-default

x-default is the answer to "what should Google show someone who matches none of my codes?" A searcher in Brazil who reads Portuguese, on a site with only en-US, en-GB and de-DE pages, is shown the page x-default names.

  • A language or country selector page is the case Google designed it for: point x-default at the selector.
  • With no selector, point it at the version most visitors can use, often your main English page.
  • Use one x-default per set, and list it on every version with the rest of the set.
  • x-default can point to the same URL as one of your coded versions, as in the example above. That is normal.

Common hreflang mistakes, and how to check yours

  1. Missing return links: a version lists the others, but they don't list it back.
  2. Wrong codes: en-UK, a country on its own, or a language code that means something else (see the table above).
  3. Relative or partial URLs: Google needs the full address, starting with https:// or http://, so /uk/pricing/ won't work.
  4. http addresses: Google says not to list the http version of a page in hreflang when an https version exists.
  5. Pointing at the wrong page: each line should name the equivalent page in that language, not the other site's homepage, and the address its canonical tag names, in the same language.
  6. The same code given to two URLs, or the same URL listed twice, within a set. The generator flags both so you can check the repeat is intended; x-default sharing a URL with one version is normal.
  7. Expecting hreflang to translate or to tell Google the language: Google detects language from the content itself, so the page still needs to be written in that language.

Search Console no longer has an International Targeting report, though Google still uses hreflang. To check a live site, open each version and view its source (or its response headers, or your sitemap) and confirm the same set is there, with the same codes. A crawler can do this across hundreds of pages. Google notes that third-party hreflang testing tools aren't maintained or checked by Google, so treat their warnings as pointers.

Hreflang is one part of a multi-country site. If you are deciding between folders, subdomains or separate domains, or your UK pages keep appearing in US results, our international SEO team can review the setup, or start with a free audit. The technical SEO service covers the canonicals and sitemaps hreflang depends on.

The short answers

What you need to know.

What is an hreflang tag?

An hreflang tag tells Google which other language or country versions of a page exist, so it can show searchers the version in their language. Each tag pairs a code, such as en-US or de-DE, with the full URL of that version: <link rel="alternate" hreflang="en-GB" href="https://www.example.com/uk/" />.

It is a map between versions, not a translation signal: Google says it doesn't use hreflang or the HTML lang attribute to work out what language a page is in.

How do I add hreflang tags to my site?

Use one of three methods, which Google treats as equivalent: link tags in the head of each page, an HTTP Link header sent with the page, or xhtml:link entries in your XML sitemap. Google says using all three brings no extra benefit, so pick one and keep it up to date.

Link tags suit most sites. The HTTP header is the only option for files without a head, such as PDFs. The sitemap keeps every set in one file, which is easier to maintain when you have many pages or can't edit page templates.

Is it en-UK or en-GB in hreflang?

Use en-GB. GB is the region code for the United Kingdom in ISO 3166-1, and UK is not an assigned region code; Google says UK in an hreflang annotation has no effect on Search. The generator flags en-UK and suggests en-GB.

Watch the other way round too: on its own, uk is the language code for Ukrainian, so hreflang="uk" targets Ukrainian speakers, not British ones.

What does hreflang x-default mean?

x-default names the page to show when none of your language or region codes matches the searcher's browser settings. Google designed it for language and country selector pages, but it can point to any page, such as your main English version.

What are hreflang return links?

Return links mean every version lists every other version, and itself. If your US page points to your UK page, the UK page must point back to the US page, or Google ignores the pair. So the same full set of tags goes on every version, with only the page it sits on changing.

Sources: Google Search Central: Tell Google about localized versions of your page; Google Search Central: How to specify a canonical URL; Search Console Help: The International Targeting report is deprecated; IANA Language Subtag Registry; Library of Congress: ISO 639 language codes; W3C: Language tags in HTML and XML.

Questions

Hreflang Tag Generator, answered.

Does each page need an hreflang tag pointing to itself?

Yes. Google says each language version must list itself as well as all the other versions, so the self-referencing line belongs in the set on every page.

Should I use HTML tags, an HTTP header or a sitemap?

Any one of them. Google treats the three methods as equivalent and says using all three adds nothing. Use link tags for normal pages, the HTTP header for PDFs and other files, and the sitemap when you have many pages or can't edit the templates.

Can I use a country code on its own, such as hreflang="gb"?

No. Google says specifying the region alone is not valid. The language always comes first, then an optional region after a hyphen: en-GB, fr-CA, es-MX. A plain language code such as en is fine.

Are hreflang codes case-sensitive?

No. Google accepts upper and lower case, so en-gb and en-GB mean the same. The usual style is a lowercase language and an uppercase region, which is what the generator writes.

Is it hreflang or href lang?

Hreflang, one word. It is an attribute of the link element that gives the language of the page at the link's href, which is where the name comes from. Written as two words it is no longer the hreflang attribute, so the generator always writes it as one.

Can hreflang point to pages on other domains?

Yes. Google says the alternate URLs don't need to be on the same domain, so example.com can point to example.de and example.co.uk, as long as each site points back.

Can I use es-419 for Latin America?

Not for Google. 419 is a United Nations region number, and Google supports only two-letter ISO 3166-1 region codes. Use plain es for a single Spanish page, or one code per country, such as es-MX and es-AR.

Should hreflang URLs be the canonical versions?

Yes. Point each line at the https address of the page, the one its canonical tag names. Google says to set a canonical page in the same language and not to list http versions in hreflang.

How do I check hreflang errors now that Search Console has no report?

Google retired the International Targeting report but still uses hreflang. Open each live version and confirm the full set appears in the page source, the HTTP response or the sitemap, with the same codes and return links on every version. A site crawler can check this across many pages.

Do I need hreflang if my site is in one language?

No. Hreflang describes alternate versions of a page, so a site with one version of each page has nothing to list. Add it when you publish a second language or a page for another country.

Is my information stored anywhere?

No. The tags are built in your browser, and nothing you type is sent to us. The generator doesn't visit your URLs, so it can't see whether your live pages already carry the tags.

A useful next conversation

Want to know what AI says about your business?

The tools show what is on your site. Our free audit looks at how ChatGPT, Google and Perplexity describe you, and what we would fix first. We send you a recorded walkthrough within 2 business days.

WhatsApp us