HandyBench

Hreflang Tag Generator

Build hreflang tags, then check them on a live page.

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

hreflang must be reciprocal: every language version should list the full set, including itself. The generator checks the code format and URLs as you type; to confirm reciprocity on a live site, use the checker below. Use a language code (en) or language-region (en-GB). x-default points crawlers to your fallback for unmatched locales.

Reads the hreflang tags (and any HTTP Link headers) on that page, then fetches up to 24 of its alternates and checks that each one links back and lists the same set. This check runs through this site's own server, so it works for any public URL — no CORS or browser restrictions.

How to use the Hreflang Tag Generator

  1. 1 Add a row for each language or region version with its code and URL.
  2. 2 Optionally set an x-default fallback URL.
  3. 3 Copy the hreflang tags into the <head> of every version.
  4. 4 After deploying, use the hreflang checker: paste the URL of any version into "Check a live page" to validate the tags and confirm every alternate has a return link and lists the same set.

What hreflang tells search engines

The hreflang attribute marks a set of pages as equivalent versions of the same content for different languages or regions, so that a French speaker in Canada is sent to the right version. Google uses it as a signal for serving the correct URL, not as a ranking boost, and it never replaces translation or localisation of the page itself. There are three equivalent places to declare it: <link> tags in the <head>, HTTP headers (useful for PDFs), or an XML sitemap. This tool produces the first: one <link rel="alternate"> line per row you enter.

Worked example

With the default rows (en to the root, en-GB to /uk/, es to /es/) and the x-default checkbox ticked, the output is:

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

Because each version must list the full set including itself, this exact same block goes into the head of all three pages. Rows with an empty code or URL are skipped (with a note), and special characters in URLs are escaped for you. The x-default line has its own URL field, which is usually the language-selector page or the version for everyone else.

The rules that make it work

  • Return links are mandatory. If page A points to page B, page B must point back to page A. One-way annotations are ignored, which is the most common reason hreflang "does nothing". The generator itself never fetches anything, but the "Check a live page" box under the tags does: see the next section.
  • Self-reference. Each page's own URL belongs in its own set.
  • x-default. It names the fallback for users whose language or region matches none of your versions. It is recommended, not required.
  • Absolute URLs. Use fully qualified URLs including the protocol, and point to the canonical, indexable version of each page.

Checking a live page for return links

Once the tags are deployed, enter the address of any one version in "Check a live page". The site's own server fetches that page, reads its hreflang annotations from the <head> and from any HTTP Link header, and then fetches each alternate (up to 24 distinct URLs; any beyond that are neither fetched nor listed, though the result says how many were left out, and alternates the request budget cannot cover are listed as not checked) and reads the set that alternate declares. Each alternate comes back as reciprocal or with the specific problems found:

  • No return link. The alternate does not list your page, so the pair is ignored.
  • Different set. The alternate omits URLs from your set, lists extra ones, or uses another code for the same URL.
  • No self-reference. The alternate does not list its own address.
  • Redirect, error status or noindex. An alternate that redirects, returns an error or is set to noindex cannot serve as a target.
  • Canonical elsewhere. The alternate's canonical tag points at a different URL.

URLs are compared exactly after the fragment is removed, so a trailing-slash difference counts as a different URL, as it does for Google. The check reads tags and headers only; annotations that live in an XML sitemap are not read, and a page that builds its tags with JavaScript will show none, because nothing is rendered. If the "Load this page's tags" button is used, the found set fills the generator rows so you can correct and re-export it.

Getting the codes right

Use a language code from ISO 639-1, optionally followed by a hyphen and a region code from ISO 3166-1 alpha-2. The language comes first, and a region on its own is not valid. The tool checks the shape of each code (2 to 3 letters, an optional 4-letter script, an optional 2-letter or 3-digit region) or x-default, flags underscores, repeated codes and relative URLs, and shows a warning under the rows. It cannot know whether a well-formed code such as en-UK is a real region, so still check the letters.

IntentCorrectCommon wrong value
English, any regioneneng
English, United Kingdomen-GBen-UK
Spanish, Mexicoes-MXes_MX (underscore)
English, United Statesen-USus (a region alone is invalid)

Only list regional variants when the content genuinely differs, such as currency, spelling or shipping. Two near-identical English pages for the US and UK are a reasonable case; ten regional copies of the same translation usually are not.

Alternates should also agree with your canonical tags; a page that canonicalises to a different URL can make its hreflang annotations get ignored. After deploying, include the translated URLs in your XML sitemap, check each page with the canonical checker, and see the meta tag generator for the other head tags a localised page needs.

Examples

  • ▸ <link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />

Frequently asked questions

Is this also an hreflang checker?

Yes. Under the generator, "Check a live page" works as an hreflang checker and validator. Enter any URL and it reads that page's hreflang tags, fetches each alternate and reports missing return links, wrong or differing sets, redirects, errors, noindex and canonical problems. You can then load the tags it found back into the generator to fix them.

Where do hreflang tags go?

In the <head> of each page (or in your XML sitemap / HTTP headers). Every language version must list the full set of alternates, including a self-reference.

What is hreflang="x-default"?

It tells search engines which page to show users whose language or region does not match any of your specific versions — usually a global or language-selector page.

What code format should I use?

Use an ISO 639-1 language code (en) optionally with an ISO 3166-1 region (en-GB), or x-default. Do not use a region alone, and note it is en-GB, not en-UK. The tool checks the shape of each code (2 to 3 letters, optional 4-letter script, optional 2-letter or 3-digit region) and warns about underscores, but it cannot confirm a code really exists, so double-check the letters.

Why is my hreflang being ignored?

The usual cause is missing return links: if page A lists page B, page B must list page A back. The "Check a live page" box tests exactly that by fetching the page and each alternate through the site server. Other causes are invalid language codes, relative URLs, or alternates that redirect, are noindexed or canonicalise to a different URL, and the checker flags those as well.

How does the live hreflang check work, and what are its limits?

It reads the hreflang annotations on the page you enter, from the head and from HTTP Link headers, then fetches up to 24 distinct alternates and compares the set each one declares with yours. It reports missing return links, differing sets, redirects, error responses, noindex and canonical mismatches. It does not run JavaScript, does not read XML sitemaps, and only reaches public pages, so private or localhost addresses are refused.

Do I paste the same tags on every version of the page?

Yes. Each version must list the full set including itself, so the same block of tags goes in the head of every language version. The generator outputs exactly that block.

Does hreflang improve rankings?

No. It does not boost rankings; it helps Google show the right language or regional version to the right user and reduces the chance that similar versions compete with each other.