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.
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.
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.
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 versionsHow 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.
-
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.
-
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. -
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.
-
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. -
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.
Hreflang tag examples
Sets in the formats this tool generates, plus the most common region code error.
<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.
<link rel="alternate" hreflang="en-UK" href="https://example.com/uk/">
<link rel="alternate" hreflang="gb" href="https://example.com/uk/"><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.
<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 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.
Hreflang requirements according to Google
| Value | What it means | Source |
|---|---|---|
| ISO 639-1 | The 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 methods | HTML tags, HTTP headers and an XML sitemap. Each passes the same information to Google. | Google Search Central, localized versions |
| 2 pages | An annotation works only when both pages point to each other. Google ignores one-way entries. | Google Search Central, localized versions |
| x-default | A 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 language | The canonical on a page with hreflang points to a page in the same language. | Google Search Central, duplicate URLs |
Sources checked:
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).
Pick one method per set of URLs. Tags in the <head> are simplest for HTML pages, the sitemap suits many versions and large URL counts, and the HTTP Link header is the only option for files without a <head>, such as PDFs.
Yes. Analysis happens in your browser and the tags you paste are not sent to CometWeb. That is also why it does not fetch pages or check HTTP status codes.
GB is a country code, not a language. The first position of the tag must be an ISO 639-1 language, with the region as an optional addition, so British English is en-GB.
No. It is optional but useful when you run several regional versions of one language, or a page with a language selector.
Google detects the language of a page on its own and, according to its documentation, uses neither hreflang nor the HTML lang attribute for that. Hreflang connects the language versions of the same content into one set.
Google treats translated versions of a page as separate pages. It considers them duplicates only when the main content stays untranslated, for example when only the navigation changes.
Hreflang for a PDF goes in an HTTP Link header, because a PDF has no head section. The generator above prepares that header, and you set it in the server configuration for each version of the file.
What else might come in handy
File or code ready? Check the result on the live page
Indexability, metadata and structure, with priorities and a client report.