Hreflang Tags Generator
Set up and launch regional language versions correctly to avoid indexing issues, and generate hreflang tags properly so search engines show the right content to the right users.
Generate hreflang tags for your pages
Enter your page URL above, pick how your language versions are structured, then tick the countries you target. The tags update automatically as you go.
What Are Hreflang Tags?
Hreflang tags tell Google which language and country each version of your page is meant for. If you have an English page for India, another for the UK and a Hindi version, hreflang helps Google show the right one to the right person. A user searching from London sees your UK page, and a user searching in Hindi sees your Hindi page. Without these tags, Google may show the wrong version, and visitors leave because the page isn’t in their language or shows the wrong currency and prices.
Why Hreflang Matters for International SEO
Expanding into new countries is one of the fastest ways to grow organic traffic. But if Google can’t tell your regional pages apart, they compete with each other, and the wrong version ranks. Correct hreflang tags help each version rank in its own market. They give every visitor a page in their language, so they stay longer and convert better.
How to Use the Hreflang Tag Generator
- Choose your URL structure: subdirectories (domain.com/uk/), subdomains (uk.domain.com) or custom URLs.
- Select your main language and country, and set it as x-default if it should serve all other users.
- Pick the other languages and countries your site targets.
- Choose your output format: HTML head tags or XML sitemap code.
- Copy the code and add it to every version of the page.
Hreflang Rules You Must Follow
- Use the correct codes. Use the language first in ISO 639-1 format (en, hi, fr), optionally followed by the country in ISO 3166-1 format (en-in, en-gb). A country code alone, like “in” or “uk”, is not valid.
- Use “gb”, not “uk”. The correct code for the United Kingdom is en-gb.
- Add return links. If page A points to page B, page B must point back to page A. Google ignores links that aren’t confirmed both ways.
- Include a self-reference. Every page should list itself in its own hreflang set.
- Use x-default for everyone else. It tells Google which page to show users who don’t match any listed language or country, often your homepage or a language selector.
- Keep canonicals self-referencing. Each language version should have a canonical tag pointing to itself, not to your main language page. Use our Canonical URL Generator to create them.
- Use full absolute URLs. Always include https:// and the full domain.
Three Ways to Add Hreflang Tags
| Method | Best For | Notes |
|---|---|---|
HTML <head> tags | Small to medium websites | Easiest to set up, but adds code to every page |
| XML sitemap | Large or e-commerce sites with many languages | Keeps page code clean and is easier to manage at scale |
| HTTP headers | PDFs and other non-HTML files | Needs server-level access |
Use one method per page. Mixing methods increases the risk of conflicting signals.
Hreflang Code Examples
HTML head tags:
html
<link rel="alternate" hreflang="en-in" href="https://www.example.com/" />
<link rel="alternate" hreflang="en-gb" href="https://www.example.com/uk/" />
<link rel="alternate" hreflang="hi-in" href="https://www.example.com/hi/" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/" />
XML sitemap:
xml
<url>
<loc>https://www.example.com/</loc>
<xhtml:link rel="alternate" hreflang="en-in" href="https://www.example.com/" />
<xhtml:link rel="alternate" hreflang="en-gb" href="https://www.example.com/uk/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://www.example.com/" />
</url>
After adding hreflang to your sitemap, run it through our Sitemap Checker to make sure it’s live and error-free.
Need Help With International SEO?
Hreflang is just one piece of ranking in multiple countries. Your URL structure, local content, site speed and backlinks all decide whether your pages win in each market. Jagdish Prajapat is a well-known SEO expert in India with 12+ years of experience and 1400+ clients worldwide. He helps businesses set up international SEO the right way, so every regional site ranks in its own market and brings in qualified customers. Book a free consultation →