Check the hreflang tags of a page

Enter the address of a page: the tool lists its hreflang declarations, checks the language codes, then reads each alternate version to check its HTTP status, its return link and its canonical.

To also list the declarations made in the sitemap. Without http:// or https://, the tool assumes https://.

    How to use the tool

    Paste the address of a page, then click “Check”. The tool reads the page and lists every hreflang declaration found in the HTML and in the HTTP Link header. If you also enter a sitemap, it looks for the page’s entry in that file and adds its declarations. Each row of the table gives the code, the URL, the source and the exact tag found, so you can locate it in the page’s code.

    The tool then reads the declared alternate pages, ten at most, after the starting page. Beyond that, it says so and leaves the rest aside. One analysis counts as a single request: the tools on this site accept twenty requests every ten minutes per visitor, all tools combined.

    Each problem found links to the rule behind it: Google’s documentation on localized versions, its documentation on canonical URLs, or the ISO standards for language and country codes.

    What the tool checks

    Three ways to declare the versions of a page

    Google reads hreflang annotations in three places and treats them as equivalent.1 The most common is the link tag, placed in the head of each version:

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

    For a file that is not an HTML page, a PDF for instance, the same information goes in the HTTP Link header, sent by the server with the response:

    Link: <https://www.example.com/guide.pdf>; rel="alternate"; hreflang="en",
          <https://www.example.com/fr/guide.pdf>; rel="alternate"; hreflang="fr"

    Finally, the sitemap can carry the annotations: under each url element, one xhtml:link element per version, the page itself included, with the xhtml namespace declared at the top of the file.1 This method lightens the code of pages on a large site, but it is harder to check, which is why the tool accepts a sitemap URL as an option. The guide on what Google says about XML sitemaps covers the rest of that file.

    Google notes that using all three methods at once brings nothing.1 Pick one and keep it up to date. When the same URL is declared under the same code by two sources, the tool does not count it as a duplicate.

    Language and region codes

    An hreflang code starts with a two-letter language from ISO 639-14: en, fr, de. It can continue with a two-letter region from ISO 3166-1 Alpha 25: fr-BE for French in Belgium, en-GB for English in the United Kingdom. Google also accepts a script in ISO 15924 format, such as zh-Hant for Traditional Chinese. Case does not matter.1

    CodeVerdictWhy
    fr-BEValidLanguage then region, both in the standards.
    zh-HantValidLanguage then ISO 15924 script.
    en-UKRejectedUK is a reserved code; the United Kingdom is GB.
    es-419RejectedRegion code outside the standards Google accepts.
    en_USRejectedThe expected separator is a hyphen.

    Google lists these traps among common mistakes: a country code used alone, or a reserved region code such as EU, UN or UK, which has no effect.1 Some two-letter codes exist in both lists with two meanings: be is the Belarusian language; Belgium is BE only in the region position, as in fr-BE. The tool cannot guess the intent in that case, so check that the code really names the language of the page.

    The x-default value names the page to show when no other language or region matches the visitor. It suits a language or country selector, or the main version of the site.1 It is optional, and the tool does not flag its absence.

    Return links, the most often forgotten rule

    An hreflang annotation only counts if both sides confirm it. If the English page lists the French page, the French page must list the English page in return; otherwise, Google ignores the tags.1 The typical case: a new language version added on one page only, or a template updated in a single language.

    The return link must target the exact URL of the starting page. A difference in protocol, www or trailing slash is enough to miss it: the tool flags this case separately, as a near-miss return link, with the URL found. It also checks that the return link uses the same code the starting page declares for itself, and that each alternate lists itself.

    For a new market, Google notes that linking the new version to the original language matters more than linking all the variants to one another.1 Connecting the new page to the old one, in both directions, comes first.

    hreflang and the canonical tag

    Both signals must point the same way. When you use hreflang, Google asks you to specify a canonical page in the same language, or the best possible substitute language if none exists.2 An English version whose canonical points to the French version asks Google to keep the French one in its place, which contradicts the annotation. The tool flags it and names the version targeted.

    Same logic for the starting page: if its canonical names another URL, Google will normally keep that other URL, and the annotations belong on it and should point to it. Google also says that, for localization, it prefers URLs that are part of an hreflang cluster2: clean annotations help the right canonical get picked.

    Two versions that differ only by region, en-GB and en-US for example, are not duplicates when their main content is adapted. Google only treats localized versions as duplicates if the main content remains untranslated.1

    What the tool cannot see

    The tool reads the HTML as the server sends it. Tags added by JavaScript after loading are not there. It does not check where the tags sit either: Google asks for them in a well-formed head and suggests an HTML validator when in doubt.1

    For a sitemap index, the tool does not open each file: enter the sitemap that lists the page. It does not follow the redirects of alternate pages, since an alternate that redirects is precisely what needs fixing. To look at one alternate page in more detail, the meta tags and Open Graph generator reads its canonical and main tags.

    Finally, Google does not use hreflang to recognize the language of a page: its algorithms handle that.1 Annotations serve to show the right version to the right visitor, among pages already indexed.

    Frequently asked questions

    Should the hreflang tag point to the page itself?

    Yes. Each version must list itself, as well as every other version. An English page therefore declares en for its own URL, then fr for the French page.

    What happens without a return link?

    If two pages don’t both point to each other, Google ignores their annotations. A page that lists a version must be listed by it in return, with its exact URL.

    Should I write en-UK or en-GB?

    en-GB. The region follows ISO 3166-1 Alpha 2, where the United Kingdom is GB. Google lists UK among reserved codes, which have no effect.

    Is x-default required?

    No. It names the page to show when no declared language or region matches the visitor. It is useful for a language or country selector page, or for the main version of the site.

    Link tag, HTTP header or sitemap: which one should I use?

    For Google, all three are equivalent. The link tag is the easiest to check, the HTTP header serves files such as PDFs, the sitemap lightens the pages of a large site. Using all three at once brings nothing.

    Can a translated page use the original version as its canonical?

    No. Google asks for a canonical in the same language. An English page canonicalized to the French page asks Google to keep the French one in its place, which contradicts the hreflang annotation.

    Sources

    Passages on this page that rely on a source point to one of these references.

    1. Google, “Tell Google about localized versions of your page”, Google Search Central. developers.google.com ↑
    2. Google, “How to specify a canonical URL with rel="canonical" and other methods”, Google Search Central. developers.google.com ↑
    3. Google, “How HTTP status codes affect Google’s crawlers”, crawling infrastructure documentation. developers.google.com ↑
    4. Library of Congress, ISO 639-2 Registration Authority, list of language codes with their ISO 639-1 equivalents. loc.gov ↑
    5. ISO, Online Browsing Platform, ISO 3166-1 country codes. iso.org ↑

    A multilingual site to put straight?

    Hreflang annotations, canonicals and the structure of language versions are part of the SEO support I offer. I reply within 24 business hours.

    Contact me