Free hreflang tool

Hreflang checker and generator

Check the hreflang tags on live pages for missing return links, missing self references, invalid codes and canonical conflicts, with the exact tag to add for each problem. Or generate a correct set for a new page.

Up to 25 URLs per run, including alternates found on the pages. Reads the HTML head and HTTP Link headers only. Nothing is stored.

ChecksWhat is tested and why

What the checker tests

Each check follows Google's documentation for localised pages. There is no score: a set of hreflang tags is either valid or it is not. When a page fails a check, the result names the page and shows the tag to add.

Errors

Google will not trust the set until these are fixed.

  • A language, script or region code that is not valid, including a region on its own
  • No self-referencing tag, compared against the final URL after redirects
  • A return link missing from the page that was pointed at
  • A page carrying fewer entries than the rest of the set
  • One hreflang value pointing at two different URLs
  • Tags found after the head has closed, or a URL that returns 4xx or 5xx

Warnings

Often deliberate. Check that the setup is what you intended.

  • A URL in the set that redirects, with the final URL shown
  • A canonical pointing at another page, in the set or elsewhere
  • A noindex in the robots meta or the X-Robots-Tag header
  • Relative hrefs, resolved for the check but not what Google asks for

Notes

Reported for information. Not a fault.

  • Whether an x-default is present
  • Tags served in an HTTP Link header rather than HTML
  • Values in unconventional case, such as zh-hk
  • A page with no hreflang at all

The checker reads the raw HTML head and the response headers of each URL. It does not run JavaScript, so tags added by scripts are not seen, and it does not read XML sitemaps yet. Only the URLs you enter and the alternates they declare are fetched. Nothing is stored.

ErrorsAs reported by audit tools

Common hreflang errors and how to fix them

These are the labels used by audit tools such as Semrush and Ahrefs. In most cases the fix is one line in one template.

  1. No self-referencing hreflangThe page lists every version except itself. Add its own URL with its own code to the same block, on every page.
  2. Missing return linksPage A points at page B, but B does not point back at A. Google requires both directions and otherwise ignores the pair. This usually happens when one template was updated and another was not.
  3. Conflicting hreflang and rel canonicalThe hreflang says this is the Japanese version, but the canonical tells Google to index the English page instead. Translated pages need a self-referencing canonical. For same-language regional copies, decide deliberately which URLs should be indexed.
  4. Invalid language or region codesen-UK, ja-JA, zh-CH and en-EU are all invalid. The language must be ISO 639-1 and the region ISO 3166-1: en-GB, ja-JP, zh-CN. Google states that EU, UN and UK have no effect.
  5. Region without a languagehreflang="HK" is invalid. A region can only follow a language: zh-HK, en-HK. Add one entry per language you publish for that region.
  6. Tags outside the head, or added by JavaScriptGoogle only reads hreflang link elements inside the head. Invalid HTML such as a stray div can close the head early, and tags injected by scripts after load are unreliable.
  7. Relative or redirecting URLsEach href must be the absolute, final URL: not /hk/, not the http version, and not a URL that redirects to a trailing slash.
  8. Inconsistent sets across the siteThe home page has the full set while product pages have whatever the template produced. Check a deep page as well as the home page, and generate the tags from one mapping.
CodesLanguage, script and region

How hreflang codes work

A value has up to three parts, always in this order. Only the language is required. The script and region narrow down who should see the page.

  1. 1. LanguagezhRequired

    ISO 639-1. Two letters, lowercase. Google specifies this list, so three-letter codes and withdrawn codes such as iw are flagged.

  2. 2. ScriptHantOptional

    ISO 15924. Four letters. Used mainly for Chinese (Hant, Hans) and for languages written in more than one alphabet.

  3. 3. RegionHKOptional

    ISO 3166-1 alpha-2. Two letters, uppercase. It cannot be used on its own, and values such as UK, EU and UN have no effect in Google Search.

Combined: zh-Hant-HK. Language tags are not case-sensitive, so zh-hant-hk also works, but the conventional spelling is easier to read and to search for in templates.

Choosing a code

When to add a region

  • Language onlyOne page serves that language everywhere. en, ja, zh-Hant.
  • Language and regionThe page is specific to a market: local prices, currency, delivery, legal text or spelling. en-HK, en-SG, ja-JP.
  • Several languages, one regionA country can need more than one language. Singapore has four official languages, so one page can carry en-SG, zh-SG, ms-SG and ta-SG, each pointing at its own translation.
  • Regional versions onlyIf you publish en-HK and en-SG but no plain en, readers elsewhere get whichever page Google prefers. Add an x-default so that choice is yours.
  • What the tag does not doIt does not set the language of the page. Google reads the content for that and ignores both hreflang and the HTML lang attribute.

Examples

Codes for Singapore, Hong Kong, Taiwan and mainland China

Singapore: four official languages

en-SG
English readers in Singapore
zh-SG
Chinese readers in Singapore. Simplified Chinese
ms-SG
Malay readers in Singapore
ta-SG
Tamil readers in Singapore

Hong Kong, Taiwan and mainland China

zh-HK
Chinese readers in Hong Kong. Traditional Chinese with Hong Kong wording
en-HK
English readers in Hong Kong
zh-TW
Chinese readers in Taiwan. Traditional Chinese with Taiwan wording
zh-CN
Chinese readers in mainland China. Simplified Chinese

Chinese by script, no region

zh-Hant
Traditional Chinese readers anywhere. Use it when one page serves Hong Kong and Taiwan together
zh-Hans
Simplified Chinese readers anywhere
zh-Hant-HK
Traditional Chinese for Hong Kong, spelled out in full. Equivalent to zh-HK in practice

Often mistyped

en-GB
United Kingdom. en-UK is not a valid code
ja-JP
Japan. ja-JA is not a valid code
zh-CN
Mainland China. zh-CH is Switzerland
en
English for Europe. en-EU is not accepted because the EU is not a country
CanonicalHow the two tags work together

Hreflang and canonical tags

Canonical says which URL to index when several are the same page. Hreflang says which indexed URL to show to which reader. Most multilingual sites need both, and they have to agree.

Translated pages

A Japanese page is not a duplicate of its English original. Each version keeps a self-referencing canonical, and the hreflang set links them. If the Japanese page canonicalises to the English one, it drops out of Japanese results.

Regional duplicates

An en-HK page and an en-SG page with the same copy are duplicates to Google. Its guidance is to pick a preferred version with rel=canonical and keep the hreflang tags, so the right regional URL can still be served. The canonical should stay in the same language.

URL variants

Tracking parameters, capitalised paths and http versions should canonicalise to the clean URL, and the hreflang set should only reference that clean URL. If the checker shows a canonical that differs from the hreflang URL, fix that first.

ImplementationChoose one method

Where to place hreflang

Google supports HTML tags, HTTP headers and sitemap entries, and says there is no benefit in Search from using more than one, only more to manage. Use one.

HTML link tags

The most common method, and what the generator on this page produces. The same block goes in the head of every page in the set. Easy to inspect, but each template has to be kept in sync.

XML sitemap

Suited to large sites and to teams that cannot edit templates. Each URL entry lists every alternate, including itself, using the xhtml namespace. One generated file covers the whole site. The checker does not read sitemaps yet.

HTTP Link header

For files without an HTML head, such as PDFs. The server sends the set in a Link header. The checker reads these headers and reports them alongside HTML tags.

FAQHreflang questions

Frequently asked questions

What does hreflang do?

It tells search engines that a group of URLs are versions of one page for different languages or regions, so they can show each reader the right one. Google recommends declaring the relationship wherever localised versions exist. It translates nothing, does not decide the page's language, and does not lift rankings by itself. It affects which version is shown.

Do I need both hreflang and canonical tags?

Usually. Canonical handles duplicates of one page; hreflang handles alternates of one page for different readers. Translated pages each carry a self canonical plus the shared hreflang set. Same-language regional copies are the special case: decide whether they should be indexed separately, then set the canonical to match rather than leaving it to the CMS default.

Is en-HK different from en?

Yes. en is English for anyone. en-HK adds a Hong Kong signal, which matters when the page carries Hong Kong pricing, delivery or legal content. If the page is the same for everyone, use en and leave the region out.

Should I use zh-HK or zh-TW?

Choose by reader, not by writing system. Both are usually Traditional Chinese, but Hong Kong and Taiwan differ in vocabulary, currency and what people search for. A page written for Hong Kong is zh-HK; for Taiwan, zh-TW. One Traditional Chinese page serving both is zh-Hant. Google detects the actual language from the content, so no tag can make a Simplified page count as Traditional.

Is x-default mandatory?

No. It names the page for readers who match none of the listed versions, and Google says it works best for language selector pages. Useful when you have a global home page or a chooser; unnecessary when every reader matches one of your versions. More on x-default above.

Can hreflang live in a sitemap instead of the page?

Yes. Google accepts HTML link tags, HTTP Link headers and sitemap xhtml:link entries, and says using more than one brings no benefit in Search. Pick one method for the whole site. This checker reads the first two today; sitemap checking is planned.

Why does an audit say I have no return tags when I can see them?

Usually the return tag names a slightly different URL: http rather than https, a missing trailing slash, www against a bare domain. Or the tag sits outside the head, or is added by JavaScript after load. Run the pair through the checker; it compares the exact final URLs and shows the tag it found on each page.

Next stepManaging SEO across multiple markets?
Desk by a window looking out over a calm sea, with a laptop, notebooks and a cup

International SEO

Managing SEO across
multiple markets?

Hreflang is one part of a wider international setup. Site architecture, localisation, canonical decisions and market-specific search demand need to work together. That is the work I do across Hong Kong, Singapore, Japan and beyond.

Explore International SEOOr ask about your site