Toolsky

Free Online Tools & Utilities for Every Task.

Hreflang Tag Generator

Generate correct hreflang tags for your multi-language website.

Hreflang Tags Output

How to use Hreflang Tags?

  • 1. Add the URLs and corresponding language/region codes for each version of your page.
  • 2. Identify one URL as the "x-default" if you have a landing page for users whose language is not supported.
  • 3. Copy the generated <link> tags.
  • 4. Paste them into the <head> section of ALL versions of the page (each version must list all versions, including itself).

A visitor in Madrid lands on your English page while an identical Spanish page sits one click away, unnoticed by Google. That mismatch is exactly what hreflang tags exist to prevent — small annotations that tell search engines "this page has versions in other languages and regions; show each audience the right one". The Hreflang Tag Generator on ToolSky builds those tags for you: supply your page URLs and their languages, and it produces correct, ready-to-paste hreflang markup without hand-writing error-prone link elements.

What Hreflang Does (and What It Does Not)

An hreflang tag is a line of HTML placed in a page's head section, declaring one alternate version of the page and the audience it serves. The value combines a language code from the ISO 639-1 standard (en, es, de, fr) with, optionally, a region code from ISO 3166-1 (GB, US, MX), written like en-GB for British English or es-MX for Mexican Spanish. A special value, x-default, names the fallback page for users whose language matches none of your versions. Google and other search engines read these annotations and use them to serve the appropriate version in each market's search results.

Just as important is what hreflang is not. It does not translate anything — you must create the translated pages yourself. It does not redirect visitors; someone who lands on the "wrong" version stays there unless your site adds its own language switching. And it is not a directive like a canonical tag: it is a strong hint that search engines follow when the annotation set is consistent, and ignore when it is contradictory.

What the Generator Produces

  • Complete tag sets: a full block of alternate link tags covering every language and regional version of a page, including each page's self-referencing tag.
  • Correct code formatting: language and region codes combined in the proper order and casing, so en-GB never comes out as GB-en.
  • An x-default entry: the fallback declaration that catches every visitor whose language you do not specifically cover.
  • Copy-ready markup: tags formatted to drop straight into your pages' head section, your CMS template, or your SEO plugin's custom field.

How to Generate Your Hreflang Tags

  1. List every version of the page: each URL together with the language (and region, if you target one) it serves.
  2. Choose your fallback page — usually your original or most general version — to serve as the x-default.
  3. Enter the URLs and their language codes into the generator on this page.
  4. Generate the tag set and review it once: every version should appear, including a tag pointing to the page itself.
  5. Copy the identical tag set into the head of every version of the page — reciprocity is what makes the system work.
  6. Repeat for each page group on your site, or implement the equivalent annotations in your XML sitemap if your site is large.
  7. After publishing, validate a page's source to confirm the tags are present and the URLs are absolute and correct.

A Worked Example: One Product Page, Three Audiences

Suppose a store sells a jacket from three URLs: the original at https://example.com/jacket in English, a Spanish version at https://example.com/es/chaqueta, and a British English version at https://example.com/en-gb/jacket. The complete tag set — identical on all three pages — is:

<link rel="alternate" hreflang="en" href="https://example.com/jacket" />
<link rel="alternate" hreflang="es" href="https://example.com/es/chaqueta" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/jacket" />
<link rel="alternate" hreflang="x-default" href="https://example.com/jacket" />

Read it as a declaration: "these four addresses are the same page for different audiences". A searcher in Spain is offered the Spanish URL, a searcher in Britain the en-GB one, and everyone else falls back to the x-default. Note the two structural rules visible in the example: the URLs are absolute (full https addresses, never relative paths), and every page carries a tag pointing at itself — drop that self-reference and search engines may discard the whole set. Sites handling many page groups often move the same declarations into their sitemap with a Sitemap Generator's output as the base, and pair hreflang with a carefully chosen canonical tag per version.

Where Hreflang Implementations Usually Go Wrong

The most common failure is a broken circle: page A lists page B as its Spanish version, but page B does not list page A back. Hreflang only counts when the annotations are reciprocal, so a one-way set is ignored — generate one set and paste it everywhere, rather than editing each page separately. Second is code misuse: regions cannot appear alone (hreflang="GB" is invalid), language codes must be the ISO short forms (en, not eng or english), and region codes must be real — inventing en-EU for "Europe" does not work.

Third, conflicts with canonical tags quietly undermine many setups: if your Spanish page canonicalises to the English page, you are telling Google the Spanish page should not exist, and it will believe the canonical over the hreflang. Each language version should canonicalise to itself. Finally, hreflang is not a geotargeting shortcut for identical content: two English pages for two countries with nothing meaningfully different (prices, shipping, spelling, contact details) rarely justify the machinery — use it where the versions genuinely serve different audiences.

Frequently Asked Questions

Do I need hreflang if my site is in only one language?

No. With a single version there is nothing to annotate. Hreflang becomes relevant the moment a page exists in two or more languages, or in distinct regional variants of one language.

What is the x-default tag for?

It names the fallback page for users whose language or region matches none of your versions — typically your original page or a language-selector page. It ensures every searcher is offered a sensible destination.

What is the difference between hreflang and a canonical tag?

A canonical tag says "this is the one true version; ignore duplicates". Hreflang says "these are parallel versions for different audiences; show each to the right people". Language versions should each carry a self-referencing canonical plus a shared hreflang set.

Should I use en or en-US for American English?

Use plain en if the page serves all English speakers. Add the region (en-US, en-GB) when the version is genuinely tailored to that country — different currency, shipping, spelling, or catalogue.

Does hreflang redirect visitors to the right language automatically?

No. It influences which URL search engines display; it does not move visitors who arrive directly. Any automatic language redirection is a separate decision for your site to implement — and should always leave a manual language switcher available.

Where else can hreflang annotations live besides the page head?

The same declarations can be delivered in your XML sitemap (as xhtml:link elements) or in HTTP response headers for non-HTML files like PDFs. The head-section method generated here is the most common and the easiest to verify.

How long until the tags take effect?

Search engines apply them as they recrawl the pages and validate the full reciprocal set. Expect days to weeks rather than hours, and make sure every version is crawlable and indexable in the meantime.

Every Audience, Offered Its Own Door

Translating a site is the expensive half of international SEO; hreflang is the cheap half that makes the translation findable. Generate the set once, apply it consistently, and each of your audiences starts meeting the version of the page that was actually made for them.