Hreflang Tag Generator
Generate hreflang tags for multilingual and multi-regional SEO
1Add language versions
2Output
<link> tags into the <head> section of each language version of your page. Every page must include hreflang tags pointing to all other versions, including itself.What Are Hreflang Tags?
Hreflang tags are HTML attributes that tell search engines which language and regional version of a page to show to users. They prevent duplicate content issues across multilingual sites and ensure the right audience sees the right version of your content.
<link rel="alternate" hreflang="es" href="https://example.com/es/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
Complete Example
Imagine you run shopglobal.com with an English page for the US and a Spanish page for Mexico. Here's how the hreflang tags should look on both pages:
shopglobal.com/en/shoes<!-- Self-reference (required!) -->
<link rel="alternate" hreflang="en-US"
href="https://shopglobal.com/en/shoes" />
<!-- Spanish version -->
<link rel="alternate" hreflang="es-MX"
href="https://shopglobal.com/es/zapatos" />
<!-- Fallback for other languages -->
<link rel="alternate" hreflang="x-default"
href="https://shopglobal.com/en/shoes" />
</head>
shopglobal.com/es/zapatos<!-- English version -->
<link rel="alternate" hreflang="en-US"
href="https://shopglobal.com/en/shoes" />
<!-- Self-reference (required!) -->
<link rel="alternate" hreflang="es-MX"
href="https://shopglobal.com/es/zapatos" />
<!-- Fallback for other languages -->
<link rel="alternate" hreflang="x-default"
href="https://shopglobal.com/en/shoes" />
</head>
- Both pages include the exact same set of hreflang tags (bidirectional)
- Each page includes a self-referencing tag pointing to itself
- The
x-defaultpoints to the English page as the fallback - All URLs are absolute (full
https://path)
How to Implement Hreflang Tags
There are three ways to implement hreflang tags. Choose the one that fits your setup:
1. HTML <head> Tags (Most Common)
Add <link> tags in the <head> section of every page version. This is the method this tool generates.
2. HTTP Headers
For non-HTML files (e.g., PDFs), use Link HTTP headers: Link: <url>; rel="alternate"; hreflang="en"
3. XML Sitemap
Add xhtml:link elements inside your sitemap. Best for large sites with many language versions.
Best Practices
- ✓ Every page must reference all language versions, including itself
- ✓ Use x-default to specify a fallback page for users whose language doesn't match any version
- ✓ Hreflang tags must be bidirectional — if page A points to page B, page B must point back to page A
- ✓ Use absolute URLs (include the full
https://domain) - ✓ Use canonical URLs — the hreflang href should match the page's canonical URL exactly
- ✓ Language codes follow ISO 639-1 (e.g.,
en,es) and region codes follow ISO 3166-1 Alpha-2 (e.g.,US,GB)
Common Mistakes to Avoid
- ✗ Missing self-reference — a page must include a hreflang tag that points to itself
- ✗ One-way links — page A references page B but page B doesn't reference page A
- ✗ Wrong language codes — using
ukfor English (UK) instead ofen-GB(uk= Ukrainian) - ✗ Relative URLs — using
/es/pageinstead ofhttps://example.com/es/page - ✗ Canonical mismatch — the hreflang href differs from the canonical URL on the target page
- ✗ Broken targets — linking to pages that return 404 or redirect to another URL
Frequently Asked Questions
Do hreflang tags affect rankings?
Not directly. Hreflang tags are a signal, not a directive. They help search engines serve the correct language version, which improves user experience and can indirectly improve engagement metrics.
What is x-default?
The x-default value specifies the fallback URL for users whose language or region doesn't match any of your hreflang tags. It's optional but highly recommended. Typically points to your main language page or a language selector page.
Should I use language only or language + region?
Use language only (e.g., es) when you have one Spanish page for all regions. Use language + region (e.g., es-MX, es-ES) when content differs by country, such as different pricing, spelling, or legal terms.
Can I use hreflang with subdomains or separate domains?
Yes. Hreflang works across subdomains (en.example.com), subdirectories (example.com/en/), and separate domains (example.co.uk). Just make sure to use absolute URLs and maintain bidirectional references.
How do I verify my hreflang implementation?
Use Google Search Console → International Targeting report to check for hreflang errors. You can also use Ahrefs, Screaming Frog, or Merkle's hreflang tag testing tool for auditing.
How long does it take for Google to process hreflang tags?
Google needs to recrawl all pages with hreflang tags before they take effect. This can take days to weeks depending on your site's crawl frequency. Submitting an updated sitemap can speed up the process.