Hreflang Tag Generator

Generate proper hreflang tags for international and multilingual websites. Create HTML link tags and XML sitemap formats to help search engines serve the correct language or regional URL to users.

Add Hreflang Entries

Enter URLs and their corresponding language/region codes

0 valid entries
Entry #1

Hreflang Best Practices

  • Every URL should reference itself in its own hreflang tags
  • Use language codes only (en, fr) unless targeting specific regions (en-US, en-GB)
  • Add x-default tag for users whose language doesn't match any hreflang
  • All referenced URLs must be canonical and return 200 status
  • Use absolute URLs including protocol (https://)

Generated Code

Choose between HTML tags or XML sitemap format

Add at least one valid hreflang entry

Entries need a valid URL and language code

Validation Status

Multiple Languages

Need at least 2 language versions

X-Default Tag

Recommended: Set a default fallback

Language Diversity

All entries use the same language

Next Step

Test your implementation with Google Search Console's International Targeting report to ensure proper hreflang setup

Quick Example

Common hreflang setup for a global website

hreflang="en-US" → https://example.com/
hreflang="en-GB" → https://example.com/uk/
hreflang="es" → https://example.com/es/
hreflang="fr" → https://example.com/fr/
hreflang="x-default" → https://example.com/

What are Hreflang Tags?

Hreflang tags are HTML attributes that tell search engines which language and regional version of a page to show users based on their location and language preferences. They're essential for international SEO and multilingual websites.

International SEO

Prevent duplicate content issues when serving similar content in multiple languages or regions

Better User Experience

Ensure users see content in their preferred language and regional variant

Key Benefit

Hreflang tags help search engines understand the relationship between multilingual or multi-regional pages, ensuring the right version appears in search results for each audience.

When to Use Hreflang Tags

✅ Use Hreflang When:

  • • You have the same content in multiple languages (English, Spanish, French)
  • • You serve regional variations of the same language (en-US vs en-GB vs en-AU)
  • • Your site has international versions targeting different countries
  • • You have duplicate or very similar content for different regions
  • • Your main content is in one language but navigation/footer is translated

❌ Don't Use Hreflang When:

  • • You only have one language version of your site
  • • Content is completely different between pages (not translations)
  • • You're just targeting keywords in different languages on the same page
  • • You use automatic/machine translation without proper localization

Understanding Language and Region Codes

Hreflang uses ISO 639-1 language codes and ISO 3166-1 Alpha 2 region codes. Here's how they work:

Language Only
hreflang="es"

Targets all Spanish speakers globally, regardless of location. Use when content is universal for that language.

Language + Region
hreflang="es-MX"

Targets Spanish speakers specifically in Mexico. Use when you have regional variations (pricing, spelling, local content).

X-Default
hreflang="x-default"

Fallback URL when no other language/region matches the user's preferences. Often your homepage or language selector page.

💡 Pro Tip

Start with language-only codes (en, es, fr) unless you truly have region-specific content. Only add region codes (en-US, en-GB) when there are meaningful differences for users in those regions.

The X-Default Tag Explained

The x-default hreflang value is a special catch-all tag that tells search engines which page to show when no language/region matches the user's preferences.

When to Use X-Default

  • • Your site serves multiple countries/languages
  • • You want a fallback for unmatched languages
  • • You have a language selector page
  • • You want to control the default user experience

What to Set as X-Default

  • • Your most universal version (often English)
  • • A language/region selector page
  • • Your primary market's version
  • • An international version without region targeting

Example Scenario:

Your site has English (US), English (UK), Spanish (Spain), and French versions. A user in Japan searches in English:

hreflang="en-US" → https://example.com/
hreflang="en-GB" → https://example.com/uk/
hreflang="es-ES" → https://example.com/es/
hreflang="fr" → https://example.com/fr/
hreflang="x-default" → https://example.com/ ← They see this

Common Hreflang Mistakes to Avoid

Missing Return Links (Most Common Error)

The Problem: Each page must list hreflang tags for all language versions, including itself. If page A links to page B, page B must link back to page A.

Wrong:
English page only references Spanish version, but Spanish page doesn't reference English
Correct:
Both pages reference each other AND themselves in their hreflang tags
Using Wrong Language/Region Codes

The Problem: Using incorrect ISO codes or mixing up language and country codes.

Wrong:
hreflang="en-UK" (UK is not a valid country code)
hreflang="sp" (should be 'es' for Spanish)
hreflang="zh-CN-Hans" (too specific, use zh-CN)
Correct:
hreflang="en-GB" (GB is the correct code for UK)
hreflang="es" (correct Spanish code)
hreflang="zh-CN" (simplified Chinese in China)
Pointing to Non-Canonical URLs

The Problem: Hreflang should only reference canonical URLs (the main version of a page), not duplicates or redirected URLs.

Wrong:
Pointing to example.com/es/ which redirects to example.com/es/home/
Correct:
Point directly to the final canonical URL: example.com/es/home/
Using Relative URLs Instead of Absolute

The Problem: Hreflang tags must use absolute URLs with the full domain and protocol.

Wrong:
href="/es/" or href="//example.com/es/"
Correct:
href="https://example.com/es/"
Mixing Up Content Types

The Problem: Hreflang should only connect equivalent pages with the same content in different languages—not different content.

Wrong:
English "About Us" page → Spanish "Contact" page
Correct:
English "About Us" page → Spanish "Acerca de" page (same content)
Forgetting to Update All Pages

The Problem: When you add a new language version, you must update the hreflang tags on ALL existing language versions to include the new one.

Solution: Use a centralized system or CMS that automatically updates hreflang tags across all pages when adding new language versions.

Implementation Methods

There are three ways to implement hreflang. You can use one or combine them:

1

HTML Link Tags (Recommended)

Add link tags in the <head> section of each page. This is the most common and straightforward method.

<link rel="alternate" hreflang="en" href="https://example.com/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/" />
✓ Easy to implement
✓ Works on any CMS
2

XML Sitemap

Add hreflang annotations to your XML sitemap. Useful for large sites or when you can't modify HTML.

<url>
  <loc>https://example.com/</loc>
  <xhtml:link rel="alternate" hreflang="en" href="https://example.com/"/>
  <xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/"/>
</url>
✓ Good for large sites
✓ Centralized management
3

HTTP Headers

Add hreflang via HTTP response headers. Useful for non-HTML files (PDFs, etc.)

Link: <https://example.com/>; rel="alternate"; hreflang="en",
      <https://example.com/es/>; rel="alternate"; hreflang="es"
✓ For PDFs & files
Less common

💡 Best Practice

Choose ONE method and stick with it. Don't mix HTML tags and HTTP headers for the same pages, as conflicting signals can confuse search engines. HTML link tags are recommended for most websites.

Real-World Hreflang Examples

E-commerce

Global Online Store

An e-commerce site selling worldwide with different currency and shipping options per region:

<link rel="alternate" hreflang="en-US" href="https://shop.example.com/" />
<link rel="alternate" hreflang="en-GB" href="https://shop.example.com/uk/" />
<link rel="alternate" hreflang="en-AU" href="https://shop.example.com/au/" />
<link rel="alternate" hreflang="de-DE" href="https://shop.example.com/de/" />
<link rel="alternate" hreflang="fr-FR" href="https://shop.example.com/fr/" />
<link rel="alternate" hreflang="x-default" href="https://shop.example.com/" />
SaaS

Software Company Blog

A SaaS company with translated blog content for different markets:

<link rel="alternate" hreflang="en" href="https://blog.example.com/seo-tips/" />
<link rel="alternate" hreflang="es" href="https://blog.example.com/es/consejos-seo/" />
<link rel="alternate" hreflang="pt-BR" href="https://blog.example.com/pt-br/dicas-seo/" />
<link rel="alternate" hreflang="ja" href="https://blog.example.com/ja/seo-tips/" />
<link rel="alternate" hreflang="x-default" href="https://blog.example.com/seo-tips/" />
Regional

Spanish Language Targeting

Targeting different Spanish-speaking countries with localized content:

<link rel="alternate" hreflang="es-ES" href="https://example.com/es/" />
<link rel="alternate" hreflang="es-MX" href="https://example.com/mx/" />
<link rel="alternate" hreflang="es-AR" href="https://example.com/ar/" />
<link rel="alternate" hreflang="es-CO" href="https://example.com/co/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

Note: Generic "es" tag covers all Spanish speakers not in specific regions

Subdomain

Language Subdomains

Using subdomains for different language versions:

<link rel="alternate" hreflang="en" href="https://www.example.com/" />
<link rel="alternate" hreflang="fr" href="https://fr.example.com/" />
<link rel="alternate" hreflang="de" href="https://de.example.com/" />
<link rel="alternate" hreflang="it" href="https://it.example.com/" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/" />

Testing Your Hreflang Implementation

Google Search Console

Free

Check the "International Targeting" report to see hreflang errors and which language versions Google has detected.

search.google.com/search-console

Hreflang Tags Testing Tool

Free

Validates hreflang implementation and checks for common errors like missing return links.

technicalseo.com/tools/hreflang/

Screaming Frog SEO Spider

Paid

Crawl your site to audit hreflang tags at scale and identify missing or incorrect implementations.

screamingfrog.co.uk/seo-spider/

Manual Testing

Free

View page source and search for "hreflang" to verify tags are present. Test with VPN from different countries to see which version Google shows.

Frequently Asked Questions

Do I need hreflang if I use separate domains (.com, .co.uk, .de)?

Yes, especially for the same language. If example.com and example.co.uk both have English content, hreflang tells Google which to show to US vs UK users. Without it, Google might show the wrong version or treat them as duplicate content.

How long does it take for hreflang to work?

Google needs to crawl and process all related pages before hreflang takes effect. This typically takes 1-4 weeks for small sites, longer for large sites. You can speed this up by submitting updated sitemaps and requesting re-indexing in Search Console.

Can I use hreflang with canonical tags?

Yes, they work together. Each language version should have a self-referencing canonical tag (pointing to itself) AND hreflang tags pointing to all language versions. Don't use a canonical tag to point to a different language version—that tells Google to ignore the current page.

Should I use language-only or language+region codes?

Use language-only (en, es, fr) unless you have region-specific versions. Add region codes (en-US, en-GB) only when content differs meaningfully—pricing, currency, spelling, local information. If your Spanish content is the same for all Spanish speakers, use just "es" rather than "es-ES", "es-MX", etc.

What if I don't have x-default?

X-default is recommended but not required. Without it, Google will choose which version to show to users whose language/region doesn't match. Setting x-default gives you control over the fallback experience, especially important for global brands.

Do hreflang tags affect my rankings?

Hreflang doesn't directly boost rankings, but improves user experience by showing the right language/region version. This leads to better engagement metrics (lower bounce rate, longer session duration) which CAN positively impact rankings. It also prevents duplicate content issues between language versions.

Can I mix subdirectories, subdomains, and separate domains?

Yes! Hreflang works across any URL structure. You can have example.com/fr/, fr.example.com, and example.fr all referenced in the same hreflang implementation. What matters is that all pages correctly reference each other.

Related Tools