SEOAnalytics Lab

Hreflang Tag Generator

Free online hreflang tag generator. List your language and country versions and copy ready-to-use hreflang tags, with an optional x-default. No signup.

Add one row for every language or country version of the page, including the page itself.

Hreflang tags (HTML)
Your hreflang tags will appear here.

Paste the same full set of tags inside the <head> of every language version listed above. Each version must link to all the others and to itself.

What is a hreflang tag?

A hreflang tag tells search engines which language, and optionally which country, a web page is written for. It also tells them where to find the other versions of the same page. With these tags in place, a search engine can show the English page to English speakers, the Spanish page to Spanish speakers and the French page to visitors in France.

Hreflang does not translate anything and it does not give you a ranking boost. Its job is to send each visitor to the right version, which lowers bounce rates and stops your translated pages from competing with each other. Our hreflang tag generator checks your language codes and addresses and builds the full set of tags for you.

When do you need hreflang?

  • Translated pages: The same page published in English, Spanish, Arabic or Urdu needs hreflang so each audience gets its own version.
  • Regional versions of one language: Separate pages for en-US and en-GB with different prices, spelling or shipping details are a classic case.
  • Multi-country stores: Product pages that change by currency or delivery country should point to each other.
  • Global brands: A main website with local sites for each market uses hreflang to connect them.
  • Partly translated sites: If only some pages exist in more than one version, add hreflang just for those pages.
  • Single-language sites: A site in one language for one audience does not need hreflang at all.

Step-by-step: building your hreflang tags

  • Add a row for each version: Type a language code, such as en or es-MX, and the full address of that version. The code field suggests common values as you type.
  • Include the page itself: Every version must list all versions, including its own address. Add a row for the current page too.
  • Choose an x-default: Turn on the x-default option and pick the page that should be shown when no listed language matches the visitor.
  • Fix any warnings: The tool shows a message for an invalid code, a duplicate language or an address that does not look right.
  • Copy and paste: Copy the tags and paste the same set into the head section of every version listed.

Understanding language and region codes

A hreflang value starts with a language code and can add a region code after a hyphen. The language comes first, in lowercase, from the ISO 639-1 list, such as en, es, fr, de or ur. The region is optional, written in uppercase, from the ISO 3166-1 list, such as US, GB, MX or PK.

You can use a language alone, like es, or a language with a region, like es-MX. You cannot use a region on its own. A common mistake is en-UK. The correct code for the United Kingdom is GB, so the right value is en-GB.

Use the simplest code that fits your pages. If one Spanish page serves everyone, es is enough. Add regions only when you really have separate pages for different countries.

What is x-default and when should you use it?

The x-default value marks the fallback page. It is shown to visitors whose language or region does not match any version in your list. Many sites use their main English page, or a page where the visitor can choose a language.

It is optional but recommended. Without it, a visitor from a country you did not plan for may land on a version that does not suit them. In the generator you can tick the x-default box and choose which of your pages it should use.

Hreflang rules you must follow

  • Link back both ways: If page A points to page B, page B must point back to page A. Without these return links, search engines may ignore the tags.
  • Add a self-reference: Each page should list itself in its own set of tags, along with every other version.
  • Use full addresses: Write complete URLs, including https and the domain. Relative paths are easy to get wrong.
  • Keep one method: You can place hreflang in the head, in HTTP headers or in an XML sitemap. Pick one method and use it consistently.
  • Match your canonicals: Each version should have a canonical tag that points to itself. If every translation points its canonical to the English page, search engines may ignore the hreflang set.
  • Point to working pages: Every address in the set should load normally, return a successful response and be open to indexing.

Common hreflang mistakes

  • Missing return links: This is the most frequent error. Every version must carry the full set of tags.
  • Wrong codes: Values such as en-UK, english or us are not valid. Use proper language and region codes.
  • Pointing to redirected pages: Use the final address, not one that redirects to another page.
  • Mixing up language and country: A country code alone, such as US, is not a language. Always start with a language.
  • Partial sets: Adding the tags to some versions but not others leaves the set incomplete and unreliable.

Hreflang in the HTML head, headers or sitemap

The generator creates link tags for the head section, which is the easiest method for most websites. It works well for sites with a small or medium number of pages. If you have thousands of pages and many languages, the tags in each page can become heavy.

In that case an XML sitemap with hreflang entries is easier to maintain, because all the information lives in one file. Non-HTML files such as PDFs can use an HTTP header instead. Whichever method you choose, keep the same information everywhere.

How to test your hreflang setup

After publishing, open each version and view the page source to confirm the tags are present and identical. Check that every address in the set loads without errors and that each page lists all the others. Search engines can take days or weeks to process the change, so test again after some time. If a wrong version still appears in the results, look for missing return links, inconsistent canonical tags and redirected addresses first.

How to use Hreflang Tag Generator

  1. Add a row for each language or country version.
  2. Choose whether to add an x-default tag.
  3. Copy the generated hreflang tags.
  4. Paste them inside the head section of every version.

Frequently Asked Questions

What is hreflang used for?

It tells search engines which language or regional version of a page to show to each visitor, which reduces duplicate content problems between translations.

Do I need hreflang if I only have one language?

No. Hreflang is only useful when you have two or more versions of a page for different languages or countries.

What is x-default?

It marks the fallback page for visitors whose language or region does not match any listed version, often an English or language-selector page.

Can I use hreflang on a single domain?

Yes. Hreflang works with subfolders such as /es/, subdomains and separate country domains. What matters is that every version has its own address and that the tags link all versions together.

Related Tools