⚡ BreezyTools Pro — Ad-free experience across all 200+ tools. Less than a coffee a month → Learn More

Hreflang Generator

Generate alternate language and region tags for multilingual pages, including optional x-default.

Waiting for complete locale rows

What hreflang does

The hreflang attribute tells search engines that several URLs hold the same content for different languages or regions. Google can then show each searcher the right version, such as the UK page to someone in London. Hreflang only affects which URL is shown. It doesn't boost rankings, translate anything, or redirect visitors.

How to use this hreflang generator

  1. Click + Add Locale for each language or regional version. Enter its code (such as en-gb) and its full URL.
  2. Optionally, enter an x-default URL for visitors who match none of your locales.
  3. Copy the tags and paste the same block into the <head> of every page in the set.

Rows that are missing a code or a URL are skipped. Codes are converted to lowercase and underscores become hyphens, so en_GB turns into en-gb. The tool doesn't check whether codes exist or URLs load, so run the checks below yourself. Nothing you enter leaves your browser.

Language and region codes

Each value is an ISO 639-1 language code. It can be followed by a hyphen and an ISO 3166-1 alpha-2 region code. A language can stand alone, but a region never can.

  • en: English for any region
  • en-us, en-gb, en-au: English for the United States, the United Kingdom, and Australia
  • es-mx: Spanish for Mexico, with es as a fallback for other Spanish speakers
  • de-ch, fr-ch: German and French pages for Switzerland

The most common mistake is writing en-uk, because the region code for the United Kingdom is gb. People also use country codes as language codes. uk is Ukrainian, se is Northern Sami (Swedish for Sweden is sv-se), and jp isn't a language code at all (Japanese is ja). Codes are case-insensitive, so en-GB and en-gb mean the same thing. They must use hyphens, not underscores.

The rules your annotations must follow

  • Self-reference: each page lists itself as well as every alternate.
  • Return links: if page A points to page B, page B must point back to A. Google may ignore annotations that aren't confirmed by a return link.
  • Absolute URLs: include the protocol and domain (https://example.com/uk/), not just /uk/.
  • Canonical, indexable targets: each URL should return a 200 status, not redirect, and not be noindexed. Each one should also have a canonical tag pointing to itself, not to the main-language version.
  • x-default: optional. It's useful for a language picker or global homepage that should catch visitors who don't match any locale.

Worked example

Say a store has US, UK, and French pages plus a global selector page. It puts this one block on all four URLs:

<link rel="alternate" hreflang="en-us" href="https://example.com/us/" />
<link rel="alternate" hreflang="en-gb" href="https://example.com/uk/" />
<link rel="alternate" hreflang="fr-fr" href="https://example.com/fr/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

The block is identical on every page, so each page references itself and links back to its siblings. If you add a fifth version later, update the block on every page, not just on the new one.

HTML tags, XML sitemap, or HTTP header

Google reads hreflang from three places. Pick one method and use it consistently. The codes and URLs you enter here work with all three.

  • HTML <link> tags in the <head>. This is what the tool produces, and it's the simplest option for small sites.
  • XML sitemap. Each <url> entry lists its alternates as <xhtml:link rel="alternate" hreflang="..." href="..." /> elements, with xmlns:xhtml="http://www.w3.org/1999/xhtml" declared. This is easier to maintain on large sites.
  • HTTP Link header. Use this for non-HTML files such as PDFs, for example Link: <https://example.com/de/guide.pdf>; rel="alternate"; hreflang="de".

Frequently Asked Questions

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

No, unless you have regional variants of the same language. A site with one language for one market gets nothing from hreflang. But US and UK pages with different prices, spelling, or shipping details should be annotated with en-us and en-gb.

What is x-default and when should I use it?

x-default marks the page for visitors whose language or region doesn't match any locale you listed. It typically points to a language selector or an international homepage. It's optional. Without it, Google picks whichever listed version it judges to be the best match.

Should each language version have its own canonical tag?

Yes. Each localized page should have a canonical tag pointing to itself. If the UK page's canonical points to the US page, you're telling Google the UK page is a duplicate. That conflicts with the hreflang annotation, and the UK version may drop out of results.

Why is Google ignoring my hreflang tags?

The usual causes are missing return links, invalid codes such as en-uk, relative URLs, and targets that redirect, are noindexed, or are blocked by robots.txt. Tags are also skipped if they end up outside the <head>, which can happen when an invalid element earlier in the head closes it early. Use URL Inspection in Search Console to see which version Google chose.

Can I combine a language-only code with regional codes?

Yes, and it's good practice. List en alongside en-us and en-gb. Google picks the most specific match, so English speakers in countries you don't target separately, such as Ireland or India, get the generic en page.

Does hreflang work across different domains?

Yes. The alternates can live on separate domains or country-code domains, such as example.de and example.fr. The same rules apply: use absolute URLs, and make sure every domain carries the full set of return links.

Power up your SEO workflow

BreezyTools Pro removes all ads, gives you early access to new tools, and supports ongoing development. Less than a coffee a month.

See Pro Plans →