Hreflang tag generator
List each version on its own line, as a code and a full URL. You get the tags, ready to paste, with warnings about common mistakes.
Free · no signup Runs in your browser
How do I write hreflang tags?
List each language or country version with its code and full URL, such as en-CA, https://example.com/ and fr-CA, https://example.com/fr/. The tool writes one link tag per version, <link rel="alternate" hreflang="en-CA" href="https://example.com/" />, which you paste into the head of every version. Each page must list itself and all the other versions, and the pages must point to each other, or Google ignores the tags.
What hreflang does, and its rules
Hreflang tells search engines which version of a page is meant for which language and region, so that a visitor in Quebec is offered the French-Canadian page and a visitor in Alberta the English-Canadian one. It is a hint, not a command, and it matters most when you have near-duplicate pages, such as English for Canada, the United States and the United Kingdom, which differ in spelling and prices but are otherwise alike.
Google's documentation sets out the rules, and almost every mistake breaks one of them. Each language version must list itself as well as all the other versions. The pages must link to each other: if page A points to B but B does not point back, the tags are ignored. URLs must be fully qualified, including https://. The code is a language in ISO 639-1 form, such as en or fr, optionally followed by a region in ISO 3166-1 alpha-2 form, such as CA; a country code on its own is not valid, and the language comes first (en-CA, never CA-en). The special value x-default marks the fallback page for visitors whose language is not listed, typically a language selector or the main version. You can declare the set in the page's HTML head, in HTTP headers (useful for PDFs) or in the XML sitemap; Google treats the three the same, so pick one and be consistent.
It runs in your browser. Nothing you enter is sent anywhere, and there is no sign-up.
A Canadian example
A Canadian business with an English and a French site could use en-CA for https://example.com/, fr-CA for https://example.com/fr/ and x-default pointing at the English home page. If the same business also sells to the United States with different prices, it adds en-US with its own URL, and every one of the three pages carries all three tags, including its own. Use the same URL in the tag as the page's canonical URL, because a tag that points at a redirected or non-canonical address is ignored.
When to use it
- Launching an English and French version of a Canadian site
- Separate pages for Canada, the United States and the United Kingdom in English
- Adding a language selector page as x-default
- Checking an existing set of tags for missing return links
Mistakes it helps you avoid
- Leaving out the self-reference.
- Writing the region without a language, or the codes in the wrong order.
- Using relative URLs.
- Tags that do not point back from the other versions.
The formula
How the answer is worked out.
1. For each version, write its code (language, optional region, or x-default) and its full URL.2. HTML: one <link rel="alternate" hreflang="code" href="url" /> per version, in every page's head.3. Sitemap: each <url> has its <loc> and one <xhtml:link> per version, itself included.4. HTTP header: Link: <url>; rel="alternate"; hreflang="code", repeated for each version.
The syntax and rules follow Google Search Central. Codes are normalised to lowercase language and uppercase region. The tool checks the shape of codes and URLs, not whether the pages exist or point back; test that on the live pages.
Example: English and French for Canada
You have en-CA at https://example.com/ and fr-CA at https://example.com/fr/.
- Line 1en-CA, https://example.com/
- Line 2fr-CA, https://example.com/fr/
- Line 3x-default, https://example.com/
Three link tags, pasted into the head of both pages
Both pages carry all three tags.
Terms on this page
- hreflang
- An annotation that links the language and regional versions of a page.
- x-default
- The fallback version for visitors whose language is not listed.
Common questions
What is hreflang?
A tag that tells search engines which language or regional version of a page to show to which visitors.
What is x-default?
The fallback page for visitors whose language or region is not listed, often a language selector.
Do I need hreflang for en-CA and fr-CA?
If you have separate English and French pages, yes: it helps the right one appear to the right visitors.
Where do I put the tags?
In the head of every version, or in the XML sitemap, or in HTTP headers. Use one method.
Is anything sent to a server?
No.
Is anything I enter sent to a server?
No. The calculation happens in your browser and nothing you type leaves your device.
Where these numbers come from
- Google Search Central — Localized versions of your pages (hreflang) Each version lists itself and all others, return links, fully-qualified URLs, x-default, and the three ways to declare them.
- Wikipedia — hreflang What the attribute is and where it came from.
Last verified 2026-10-25 The method on this page is checked against the sources above at least once a year. Spotted something out of date? Tell us and we will fix it.
Related tools
Meta tag generator
Create the title, description, canonical, robots, Open Graph and Twitter card tags for a page, with a share preview, and copy the HTML.
Open toolSitemap generator
Paste your page addresses and get a valid sitemap.xml file to upload, with an optional last-modified date.
Open toolRobots.txt generator
Build a robots.txt file with allow and disallow rules and your sitemap address, ready to copy.
Open toolFAQ schema
Write your questions and answers and get FAQPage JSON-LD markup to paste into a page, with a note on when Google shows it.
Open toolhtaccess redirects
Generate Apache .htaccess rules for 301 redirects, forcing HTTPS, choosing www or non-www, a custom 404 page and switching off directory listing.
Open toolSchema markup generator
Generate JSON-LD structured data for an organization, local business, article or breadcrumb trail, with checks for missing fields.
Open tool🔎 SEO tools
Small SEO jobs done in your browser: previews, checkers and generators. Nothing you enter is sent anywhere.
See all 12 tools in this section