Hreflang Generator

Hreflang tags generated—
Languages covered—
How to use—

How Hreflang Generator is calculated: One link tag per language version — rel=alternate, hreflang={language}, href={url} — plus one x-default tag pointing at the default page.

What is hreflang and why do multilingual sites need it?

Hreflang is a small tag that tells Google which language and region a page is written for. When the same page exists in English, Hindi, and American English, Google sees three pages with nearly identical content. Without hreflang, it has to guess which one to show each searcher — and it often guesses wrong, showing the Hindi page to someone in London or the US page to someone in Delhi.

The tag itself is one line of HTML placed in the head of a page. It names a language, such as en or hi, and the URL of the version written in that language. A page that lists all its versions this way gives Google a clear map: this URL is the English version, that URL is the Hindi version, and the third is the fallback for everyone else.

Any site with translated or regional pages needs it. A shop that sells in India and the US, a blog that publishes in English and Hindi, a company site with a UK version and a US version — all of them have pages that look like duplicates to a search engine. Hreflang is the signal that says these are not duplicates, they are the same content aimed at different readers.

How this hreflang generator builds your tags

This page builds the whole hreflang block for you. Type the default URL of the page, then add up to three language versions: a language code and the URL of that version. Click the button and the page writes one link tag per version, plus an x-default tag that points at the default page. The block appears in the output box, ready to copy.

The pattern is the same on every line: a link tag with rel set to alternate, hreflang set to the language code, and href set to the version URL. The x-default line is the same shape, with hreflang set to x-default instead of a language. That line tells Google which version to show when no language matches — usually the default or language-picker page.

Nothing is uploaded and nothing is stored. The tags are built in your browser from the URLs you typed, and the page never sees your site. Once you have the block, a meta tag generator can help with the other tags that belong in the same page head, such as the title and description.

Language codes, region codes, and x-default explained

A language code follows the ISO 639-1 list: two letters for the language. English is en, Hindi is hi, Spanish is es, French is fr, German is de. A region code can be added after a hyphen, using the ISO country code: en-US is English for the United States, en-GB is English for the United Kingdom, es-MX is Spanish for Mexico. The language part is required; the region part is optional.

The most common mistake is writing the code the wrong way round or inventing one. The order is always language first, then region: en-US is right, US-en is wrong. And the codes are fixed — there is no code for American as a language, only en-US. If you are unsure of a code, check the ISO lists rather than guessing, because Google ignores tags with codes it does not recognise.

The x-default tag is the fallback. It points at the page a visitor should land on when their language matches none of your versions — often the default language page, or a page that lets the visitor pick a language. Every hreflang set should have one. Without it, Google picks a version itself, and that pick is often the one you would not have chosen.

A worked example: three versions of one page

Take a company about page, https://example.com/about, published in three versions: a plain English version at https://example.com/en/about, an American English version at https://example.com/us/about, and a Hindi version at https://example.com/hi/about. Type the default URL, the three codes en, en-US and hi, and the three version URLs into this generator and click the button.

The output is four lines. The first three name the versions: hreflang en pointing at the English URL, hreflang en-US pointing at the US URL, and hreflang hi pointing at the Hindi URL. The fourth line is the x-default tag pointing back at https://example.com/about, the default page. Four tags, three languages, one fallback.

Paste that block into the head of every version of the page — not just the default one. Each version must list all the others, including itself. That sounds odd, but it is how Google checks the set: every page in the group must confirm the same list. A version that is missing from the list breaks the whole set for that page.

Who uses hreflang tags

International shops use them most. A store selling in India, the US, and the UK has three versions of every product page, with different prices, currencies, and shipping notes. Hreflang keeps the Indian buyer on the rupee page and the US buyer on the dollar page, which is worth real money: a buyer who lands on the wrong currency usually leaves instead of converting.

Publishers with translated content use them next. A blog that writes in English and Hindi, or a news site with regional editions, uses hreflang so each reader finds the edition in their own language. Without it, the two editions compete with each other in search results, and the wrong one often wins for a given reader.

Even single-language sites use hreflang when they serve regions differently. A site in English for the US and English for the UK has the same words but different spelling, prices, and contact details. The en-US and en-GB tags keep each audience on its own version. Before publishing, a SERP preview tool shows how each version will look in the search results.

Hreflang tags vs a sitemap with hreflang

There are two places to put hreflang: in the head of each page, or in the XML sitemap. Both work, and Google accepts either. Page tags are the common choice for small sites because they sit next to the content and are easy to check by viewing the page source. A sitemap keeps the tags in one file, which is easier to manage when a site has thousands of pages.

The generator on this page builds the page-head version. If your site has a few dozen translated pages, paste the block into each page and you are done. If it has thousands, the same lines can be generated for the sitemap instead — the format is identical, only the wrapper changes. Either way, the rule is the same: every version lists every other version.

One practical difference matters. Page tags are checked when Google crawls the page, so a mistake shows up quickly. Sitemap tags are checked when Google reads the sitemap, which can be slower, and a broken sitemap can hide every tag at once. For that reason, many sites use page tags first and add the sitemap version later. A sitemap generator builds the sitemap file itself if you take that route.

Common hreflang mistakes

The first mistake is listing a version that does not exist. Every URL in the block must return a real page with a 200 status. A hreflang tag pointing at a 404 page or a redirect is ignored, and if enough tags are broken Google may ignore the whole set. Check every URL before you paste the block.

The second mistake is forgetting the return link. If page A lists page B, page B must list page A. A one-way link is treated as an error, and the pair is dropped from the hreflang map. This is the most common hreflang bug on real sites, because one page gets updated and the others are forgotten.

The third mistake is mixing languages and regions up. Writing en-UK instead of en-GB, or using a country code where a language code belongs, makes the tag invalid. The title tag checker will not catch this — hreflang has its own rules, and the only check is the code list itself. The fourth mistake is putting the tags on only one version of the page. Every version needs the full block, including itself.

How to use this hreflang generator

Start with the default page URL — the page that visitors land on when no language matches. Then fill in each language version: the code in the language box, the version URL in the URL box. Use the ISO codes: en for English, hi for Hindi, en-US for American English. Leave a language pair blank if you have fewer than three versions.

Click Generate Hreflang Tags. The results box shows how many tags were built and which languages they cover, and the output box shows the full block. Copy it and paste it into the head of every version of the page, including the default one. Each version gets the same block.

After pasting, check the work. Open each version, view the page source, and confirm the block is there. Then wait for Google to recrawl the pages — the right version usually starts appearing in search results within a few days. If a version keeps showing to the wrong audience, re-check the return links first; that is the usual cause.

Frequently Asked Questions

Usually not, unless you serve different regions in English. A site with a US version and a UK version — different prices, spelling, and contact details — needs en-US and en-GB tags so each audience lands on its own version. A single English site with one version for everyone needs no hreflang at all.

It is the fallback version Google shows when a searcher's language matches none of your versions. It usually points at your default language page, or at a language-picker page. Every hreflang set should include one, so Google never has to guess which version is the default.

Yes. Google accepts hreflang in the XML sitemap as well as in the page head, and the tag format is the same. Page tags are easier to check on a small site; a sitemap is easier to manage on a site with thousands of translated pages. Do not use both for the same pages — pick one place and keep it consistent.

The usual cause is a missing return link: page A lists page B, but page B does not list page A, so Google drops the pair. Other causes are tags pointing at pages that redirect or return 404 errors, and invalid language codes such as en-UK instead of en-GB. Fix the return links first, then wait for a recrawl, which usually takes a few days.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.