Skip to content

Hreflang Generator

Build alternate hreflang link tags from a page URL, a language, and one alternate per line.

Result

Enter a page and its alternates

How to Use

  1. 1 Enter the URL of the page you are marking up.
  2. 2 Enter its language code and, when needed, a two-letter region.
  3. 3 Add one alternate per line, as a language code followed by its URL.
  4. 4 Add an x-default URL when one page should be the fallback.

Example Output

  • en https://www.example.com/en/
  • fr-FR https://www.example.com/fr/

About This Tool

Hreflang tags tell a search engine which language and regional URL corresponds to a page. This generator writes the link elements. It does not submit them to a search engine.

Using the Hreflang Generator

Hreflang markup tells a search engine which URL serves which language or region. A French page and an English page can describe the same offer, and the tags help the engine choose the URL that matches the reader. This generator writes those link elements from the URL, language, and region you enter.

The result is HTML you can place in the head of the page. It does not publish the page, submit a sitemap, or change a server. Copy the tags only after the codes and URLs match the pages you actually serve.

What Is an Hreflang Tag?

An hreflang tag is a link element with rel="alternate" and an hreflang value. The value names a language, and it can also name a region. The href is the absolute URL of the page written for that audience. Together, the tags on a page form a small map of its alternates.

The language is not a guess from the words on the page. You choose it. A page written in English for readers in the United States can use en-us. A page written in French for France can use fr-fr. A page that is simply English, with no regional URL of its own, can use en.

Search engines use the map when the same content exists in more than one language or market. Without the map, the engine still crawls the URLs it can find, but it has less explicit help when two URLs are translations of each other. The tag does not replace a title, a canonical link, or a readable page. It only names the alternate.

Use the tags on pages that have real counterparts. A tag that points at a missing URL, a redirect, or a page in the wrong language creates a map the engine cannot trust. Generate the markup for the set you can stand behind, and update it when a locale is added or removed.

How the Hreflang Generator Works

The generator reads five inputs. The page URL is the address of the page you are marking up. The page language is a two- or three-letter code. The region is optional and must be two letters when you enter it. The alternates box takes one language-and-URL pair per line. The x-default URL is optional.

Each URL must be absolute and must begin with http:// or https://. A path such as /fr/ is rejected because a search engine needs the host. A code is lowercased in the finished tag. If you type en and US, the tag uses en-us. Typing the region in lowercase is accepted and stored the same way.

The page itself becomes the first tag, using the language and region you entered. Each alternate line becomes another tag. A non-empty x-default URL becomes a final tag whose hreflang value is x-default. The generator then refuses a repeated code. Two lines that both say fr-fr, or a page set to en and an alternate that also says en, stop the run with an error instead of emitting a broken pair.

The output is plain text, one link element per line. Characters that would break an attribute are escaped. Copy that block into the head of the page whose URL you entered. Other pages in the set need their own copies, with the same URLs, so the relationship is reciprocal. A Robots.txt Generator answers a different question: which paths a crawler may fetch. Hreflang answers which fetched URL matches which language.

Language and Region Codes

Language codes on this page follow a short practical pattern. A language is two or three letters, such as en, fr, de, pt, or cmn. A region, when you add one, is two letters, such as US, GB, BR, or CA. In an alternate line you may also type the combined code yourself, such as pt-br or en-gb.

Do not invent a code because it looks like an abbreviation of a country name. UK is not the region code people expect for the United Kingdom in this system; GB is the usual region code. The generator will accept UK because it is two letters, so the responsibility for choosing the real code stays with you. Check a code against the set your site already uses before you generate a new cluster.

Script and extended codes are allowed in an alternate line when they fit the pattern of a language plus hyphenated parts, such as zh-hans. The page-language field itself stays a language without a region, because the region has its own box. If you only have a combined code for the current page, put the language in the language box and the region in the region box.

How to Use the Hreflang Generator

Start with one page in the cluster. Paste its full URL, including the scheme and host. Enter the language that page is written in. Add a region only when that page is meant for a specific market rather than for every speaker of the language.

Worked Markup Examples

Take a site with an English page at https://example.com/en/, a French page at https://example.com/fr/, and a German page at https://example.com/de/. On the English page, the page URL is the English address, the language is en, and the region is empty. The alternate lines are fr followed by the French URL, and de followed by the German URL. The generator writes three tags: en, fr, and de.

The same three URLs should appear on the French page and on the German page. Generate again with the French URL as the page URL and French as the page language, and list English and German as alternates. The cluster is consistent when every page lists the same set. A Sitemap Validator can help you inspect a sitemap file, but it does not write these link elements. The tags still belong in the page or in a sitemap that your own publishing system builds from the same URLs.

One English page with two alternates and a fallback
Role Code entered URL
Current page en https://example.com/en/
Alternate fr https://example.com/fr/
Alternate de https://example.com/de/
Fallback x-default https://example.com/

Return Links

Hreflang is a set, not a one-way pointer. If the English page names the French page, the French page should name the English page. A tag that is not returned from the other URL is a weak signal. The generator builds the tags for the page you are editing. It cannot log into the other pages and insert the matching tags for you.

Common Mistakes to Avoid

The most common mistake is a relative URL. /fr/ looks obvious to a person who is already on the site, and it is not a valid href for this tool. Paste the full address, including https and the host. A second mistake is using a country name instead of a language. France is not a language code. French is fr. France as a region is a separate choice, written as fr-fr when the page is French for that market.

After you generate a cluster, compare it with a checker that looks at published tags. The Hreflang Validator is the inventory tool aimed at checking codes that are already in place. This page writes the tags. It does not crawl your live site.

Tips for Accurate Tags

Keep a simple table of the cluster: code, URL, and the date you last checked that the URL returns the page you expect. Generate from that table. When a new locale launches, add one row and regenerate every member of the set so the return links stay complete.

Tags do not fix a thin title or a description that is too long for the result snippet you want. Copy, titles, and descriptions are separate jobs. A Meta Description Length Checker looks at description length. Use it when you are editing the snippet, not when you are deciding the language of the URL.

Limitations of the Generator

The generator does not fetch the URLs. A well-formed address can still be a 404, a login wall, or a page in a different language from the code you typed. Open the URL yourself. The tool also does not know your canonical link. If a page canonicalizes to a different address from the one you put in the tag, the cluster and the canonical are in conflict, and this page will not notice.

Checking the Markup Before You Publish It

Read the generated block once before you paste it. Count the tags. The count should equal the current page, plus each alternate line, plus one if you set x-default. Open every href. Confirm the page that loads is in the language the code names. Confirm the return page lists this URL with the matching code.

Crawler rules still apply to every URL in the cluster. A page that is disallowed cannot act as a useful alternate. If you are editing crawl rules at the same time, check them with the Robots.txt Validator and then return to the hreflang set. The two files answer different questions and should not contradict each other by accident.

Frequently Asked Questions

What does the hreflang generator produce?

It produces HTML link elements with rel="alternate", an hreflang code, and an absolute URL. One element is written for the current page, one for each alternate line, and one more when you supply an x-default URL.

Where should the tags go?

Place them in the head of the page whose URL you entered, or generate the same set from your template. They are not visible body text and they are not navigation links for readers.

Can I use a relative URL?

No. Each address must start with http:// or https:// and include a host. A path such as /fr/ is rejected so the tag does not depend on the page the reader happens to be viewing.

What is x-default?

x-default marks a fallback URL for readers whose language is not in the cluster. Leave the field empty when you do not want a fallback. It is not a language code.

Why was a code rejected as a duplicate?

Each hreflang value can appear once. The current page and an alternate cannot share a code, and two alternate lines cannot share one either. Give different markets different region codes, or keep a single URL for that language.

Does the region change the language?

The region narrows the audience. en is English in general. en-us is English aimed at the United States. Add a region only when you have a page for that market.

Do the other pages need tags too?

Yes. Generate the set again with each URL as the current page so every member of the cluster lists the others. A one-way tag is an incomplete map.

Will this submit my site to a search engine?

No. The tool writes markup and copies it. Publishing the page, allowing it to be crawled, and any submission process stay on your site.

Can one URL be tagged as several languages?

Only if you deliberately give that URL several codes. That claim is rarely true. Create a tag for a language when a page in that language exists.

Does the generator check that the URL works?

No. It checks that the URL is absolute and that the code has a valid shape. You still need to open the page and confirm the language.

How do I repeat a cluster later?

Keep the table of codes and URLs. The form does not store the cluster after you reset it or leave the page. Generate again from the table when a URL changes.

Is hreflang the same as a canonical link?

No. A canonical link names the preferred URL among duplicates. Hreflang names language and regional alternates. A page can need both, and they should name URLs that agree with each other.