Skip to main content
Free tool

Hreflang generator & checker

Generate a set or check yours, locally in your browser

  • Free
  • No account required

Language versions of the same page

–
–

Pick from the list or type a code: language per ISO 639-1, region per ISO 3166-1. British English is en-GB, not en-UK.


The version for visitors whose language matches none of the above, such as a language selector page.

Set check

Add at least two versions

Enter the language, an optional region and the full URL of each version. The code updates as you type and nothing is uploaded.

HTML <head>

The code appears once you add versions…

The hreflang generator turns a list of language versions into ready <link> tags for the <head>, XML sitemap entries and an HTTP Link header. The hreflang checker validates pasted annotations locally in your browser: language tag syntax, self referencing hreflang, absolute URLs, duplicates and x-default. It does not fetch pages, so it cannot prove reciprocity between two URLs. Instead it generates the set every language version has to carry.

About the tool

Why hreflang usually fails

The most common cause is a missing self reference. Teams declare only the "other" versions, but the annotations describe the whole cluster, so without a self reference the set can be disregarded entirely.

The second is a missing return tag. If A names B, B must name A. That cannot be checked from one page, which is why this tool generates the set you paste onto every version.

The third is URLs that do not return 200. An entry pointing at a redirect, a 404 or a noindex page does not work and can invalidate the whole set.

Validation runs locally in your browser and the tags you paste are not sent to CometWeb. This tool checks neither HTTP status nor reciprocity, because it fetches nothing.

In practice

Connect equivalent content

Build a set of language versions for the same product, article or category. Do not connect unrelated topics simply because they use different languages. Review language and region codes and destination URLs before copying the tags.

Google Search Central, Localized versions
Step by step

How to add hreflang to the language versions of a page

You add hreflang as one set of annotations that describes every language version of the same page. The set is identical on each version, including the entry for the page itself.

  1. List the versions of the same page

    Write down the full URL of each language version of one page, for example the Polish and English pricing pages. Each URL should return 200 and carry a canonical to itself.

  2. Choose the language and region codes

    The language uses an ISO 639-1 code (pl, en), and an optional region follows a hyphen as an ISO 3166-1 Alpha 2 code (en-GB). The country code always follows the language code. The generator above lets you pick both from a list.

  3. Add x-default

    x-default points to the page for people whose language settings match no version, such as a language picker page. It is optional, but useful when you run several regional versions.

  4. Pick one method and add the set to every version

    The generator outputs the same set as <head> tags, XML sitemap entries and an HTTP Link header. Choose one method and put the set on every version, because Google ignores annotations without a return link.

  5. Check the published pages

    Copy the tags from each published version and paste them into the checker mode together with the page URL. The checker confirms the syntax, absolute URLs and the self reference. Check HTTP status codes separately.

Examples

Hreflang tag examples

Sets in the formats this tool generates, plus the most common region code error.

Set in the <head> with x-default
<link rel="alternate" hreflang="pl" href="https://example.com/pl/cennik">
<link rel="alternate" hreflang="en" href="https://example.com/pricing">
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing">

The same block goes into the <head> of both versions. The Polish page lists itself, and so does the English one.

Region code in place of a language code
Before
<link rel="alternate" hreflang="en-UK" href="https://example.com/uk/">
<link rel="alternate" hreflang="gb" href="https://example.com/uk/">
After
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/">

The ISO 3166-1 code for the United Kingdom is GB. The region always follows the language code.

XML sitemap entry
<url>
  <loc>https://example.com/pl/cennik</loc>
  <xhtml:link rel="alternate" hreflang="pl" href="https://example.com/pl/cennik"/>
  <xhtml:link rel="alternate" hreflang="en" href="https://example.com/pricing"/>
</url>

The <urlset> element must declare xmlns:xhtml="http://www.w3.org/1999/xhtml". The English version gets its own <url> element with the same set.

Common mistakes

Common hreflang implementation mistakes

  • The set on only one version

    Google ignores the annotations if two pages do not point to each other. A set added only to the Polish version starts working once the English page links back to the Polish one.

  • Missing entry for the page itself

    Each language version must list itself as well as all other versions. Teams often list only the "other" languages.

  • Relative URLs

    Google requires full URLs with the protocol, such as https://example.com/pl/. Paths such as /pl/ and //example.com/pl/ need the protocol and host added.

  • Canonical to another language version

    A Polish page with a canonical to the English page sends a conflicting signal. Google recommends a canonical to a page in the same language.

  • Hreflang on a page that is not translated

    Google treats language versions as duplicates only when the main content stays untranslated. Translate the content before you mark the page as a language version.

Numbers and sources

Hreflang requirements according to Google

ValueWhat it meansSource
ISO 639-1The language code standard for hreflang. The region uses an ISO 3166-1 Alpha 2 code, and only together with a language.Google Search Central, localized versions
3 methodsHTML tags, HTTP headers and an XML sitemap. Each passes the same information to Google.Google Search Central, localized versions
2 pagesAn annotation works only when both pages point to each other. Google ignores one-way entries.Google Search Central, localized versions
x-defaultA reserved value for when no other language or region matches the browser settings.Google Search Central, localized versions
http(s)Alternate URLs must be fully qualified, including the protocol.Google Search Central, localized versions
Same languageThe canonical on a page with hreflang points to a page in the same language.Google Search Central, duplicate URLs

Sources checked:

Glossary

Parts of an annotation

SRSelf referencing hreflang
The entry pointing at the URL of the page carrying it. Required in every complete set.
RTReturn tags
Reciprocity: if A declares B, B must declare A. One-sided annotations are ignored.
XDx-default
The version for audiences outside the declared languages and regions, a language selector, for instance.
BCPBCP 47
The language tag standard: language (pl), language-REGION (en-GB), optionally with a script (zh-Hant-TW).
SEO module in Insight

File or code ready? Check the result on the live page

Indexability, metadata and structure, with priorities and a client report.