Hreflang Tag Generator

Generate hreflang tags for international SEO. Create proper hreflang implementation for multilingual websites with x-default support.

TL;DR: Hreflang tags tell Google which language version of a page to show in each country. Get them wrong and your German visitors see your English page, your French page competes with your Canadian French page, and everyone's confused. This free hreflang generator creates properly formatted tags you can copy directly into your site.

What Are Hreflang Tags and Why They Matter for International SEO

If you have content in multiple languages or target multiple countries, you need hreflang tags. Without them, Google guesses which version to show, and Google often guesses wrong.

Hreflang is an HTML attribute that tells search engines: "This page has alternate versions in other languages or for other regions. Here's where to find them." When someone in Germany searches, Google shows your German page. When someone in France searches, they get your French page. That's the goal.

The problem? Hreflang implementation is notoriously tricky. Studies show that most multilingual websites have hreflang errors. Missing tags, wrong language codes, broken reciprocal links. This tool helps you avoid those mistakes.

How to Use This Hreflang Tag Generator

This tool creates valid hreflang tags for all your language and regional page variations:

  1. Add your page URLs for each language/region version.
  2. Select the language code (e.g., en, de, fr, es) for each URL.
  3. Optionally add a region code (e.g., US, GB, DE) for geo-targeting.
  4. Set your x-default (the fallback page for unmatched visitors).
  5. Copy the generated tags and add them to each page.

The generator automatically creates reciprocal tags. Every page needs to reference every other page, including itself. We handle that complexity for you.

Understanding Hreflang Language Codes

Hreflang uses ISO 639-1 language codes, optionally combined with ISO 3166-1 Alpha-2 country codes. Here are the most common combinations:

Common Hreflang Language Codes

Code Target When to Use
en English (all regions) One English version for everyone
en-US English (United States) US-specific content, pricing, spelling
en-GB English (United Kingdom) UK-specific content, GBP pricing
de German (all regions) German for Germany, Austria, Switzerland
de-AT German (Austria) Austria-specific German content
fr French (all regions) One French version globally
fr-CA French (Canada) Canadian French, CAD pricing
es Spanish (all regions) One Spanish version globally
es-MX Spanish (Mexico) Mexico-specific Spanish content
x-default Fallback for unmatched users Language selector or main version

Important: Language codes are lowercase (en, de, fr). Country codes are uppercase (US, GB, DE). The format is always language-COUNTRY, never the reverse.

Three Ways to Implement Hreflang Tags

You can add hreflang tags in three places. Choose the method that works best for your website localization setup:

Method 1: HTML Link Tags (Most Common)

Add link tags in the <head> section of each page:

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

Best for: Most websites, CMS-managed sites, WordPress with plugins.

Method 2: HTTP Headers

For non-HTML files (PDFs, documents), use HTTP headers:

Link: <https://example.com/file.pdf>; rel="alternate"; hreflang="en",
      <https://example.com/de/file.pdf>; rel="alternate"; hreflang="de"

Best for: PDF files, non-HTML resources you want indexed in multiple languages.

Method 3: XML Sitemap

Add hreflang annotations to your XML sitemap:

<url>
  <loc>https://example.com/page/</loc>
  <xhtml:link rel="alternate" hreflang="en" href="https://example.com/page/" />
  <xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/page/" />
  <xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/page/" />
</url>

Best for: Large sites with thousands of pages, sites where editing HTML is difficult.

Common Hreflang Errors and How to Fix Them

These are the mistakes I see most often on multilingual websites. Use an hreflang checker to audit your site after implementation:

Missing return tags (non-reciprocal)

Page A links to Page B, but Page B doesn't link back to Page A. Every page must reference every alternate, including itself. This is the #1 hreflang error.

Wrong language codes

Using "uk" for Ukrainian (correct: "uk") but also using "uk" when you mean United Kingdom (correct: "en-GB"). Or using three-letter codes (eng instead of en).

Missing self-referential tag

Each page must include an hreflang pointing to itself. The English page needs hreflang="en" pointing to its own URL.

Conflicting with canonical tags

Hreflang URLs must match your canonical URLs exactly. If your canonical has a trailing slash, your hreflang must have one too.

Linking to non-indexable pages

Hreflang pointing to pages with noindex, 404 errors, or redirects. All hreflang URLs must be 200 status, indexable pages.

Hreflang vs Canonical Tags: How They Work Together

This confuses a lot of people. Here's the difference:

Tag Purpose Example
Canonical Points to the preferred version of duplicate pages /page/ and /page?ref=123 both canonicalize to /page/
Hreflang Points to language/regional equivalents /page/ (en) and /de/page/ (de) are equivalents

Rule: Each page should have one canonical (pointing to itself or its master version) AND hreflang tags pointing to all language versions. The hreflang URLs should match the canonical URLs of each language version.

Hreflang for WordPress Sites

WordPress multilingual sites can implement hreflang several ways:

  • WPML — Automatically generates hreflang tags when you connect language versions. Most popular solution for multilingual WordPress.
  • Polylang — Free alternative that also handles hreflang automatically when languages are linked.
  • Yoast SEO Premium — If using subdirectories or subdomains, Yoast can add hreflang tags in settings.
  • Manual implementation — Use this generator and add tags via your theme's header.php or a plugin like "Insert Headers and Footers".

Whatever method you use, always verify with an hreflang checker afterward. Plugins can misconfigure tags, especially after updates.

Testing Your Hreflang Implementation

After adding hreflang tags, validate them:

  1. View page source — Check that hreflang tags appear in the HTML head of each page.
  2. Verify reciprocal tags — Visit each language version and confirm it links back to all others.
  3. Use an hreflang checker tool — Tools like TechnicalSEO.com's hreflang checker crawl your pages and report errors.
  4. Check Google Search Console — Under International Targeting, Google reports hreflang errors it detected during crawling.

Frequently Asked Questions

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

x-default specifies a fallback page for users who don't match any of your targeted languages or regions. Use it to point to your main language version, a language selector page, or your homepage. Every hreflang set should include an x-default.

Do I need hreflang if I only target one country?

No. Hreflang is only needed when you have multiple language or regional versions of the same content. If you have one English site targeting the US only, you don't need hreflang. Use geo-targeting in Google Search Console instead.

Should I use subdirectories, subdomains, or separate domains?

All three work with hreflang. Subdirectories (example.com/de/) are easiest to manage and consolidate domain authority. Subdomains (de.example.com) offer more separation. Separate ccTLDs (example.de) provide strong geo signals but split authority. Choose based on your business needs, not SEO alone.

Does hreflang affect rankings?

Hreflang doesn't directly boost rankings. It helps Google serve the right page to the right user, which improves user experience and can reduce bounce rates. Better engagement signals can indirectly help rankings over time.

How do I handle pages that exist in only some languages?

Only include hreflang for pages that actually have equivalents. If your German blog post doesn't have an English version, don't add hreflang to it. Don't link to your homepage as a "substitute" for missing translations.

Can I use hreflang with AMP pages?

Yes. AMP pages should have hreflang tags just like regular HTML pages. Make sure both the AMP version and the canonical HTML version have matching hreflang configurations.

Why is Google showing the wrong language version?

Common causes: missing or incorrect hreflang tags, non-reciprocal links, conflicting canonical tags, or the alternative page has quality issues. Use an hreflang checker to diagnose, and verify in Google Search Console's International Targeting report.

Get Your International SEO Right

Hreflang is one of the most error-prone parts of multilingual SEO. But when implemented correctly, it ensures your content reaches the right audience in the right language. Remember: hreflang handles which page to show, but you still need proper international keyword research to know what content to create for each market.

Use the hreflang generator above to create valid tags for all your language versions. Test with an hreflang checker, add the tags to your pages, and monitor in Google Search Console for any issues.

Related Free SEO Tools

International SEO requires multiple elements working together: