Skip to main content
← Browse All How-To Guides
Hreflang & Technical SEO~11 min read

Hreflang Implementation & Testing Guide: HTML Tags, XML Sitemaps & Common Errors

Step-by-step tutorial on how to implement hreflang tags cleanly in HTML, XML sitemaps, and Next.js—plus how to check return tags, x-default, and regional ISO codes without losing rankings.

Symmetrical bidirectional hreflang network linking regional pages with verified checkmarks

How Does Hreflang Implementation Work?

Hreflang implementation maps equivalent multilingual URLs using valid BCP-47 language-region codes such as en, de-DE, de-AT, de-CH, and x-default. To prevent Google from ignoring your cluster, deploy one primary method (HTML <head>, XML sitemap, or HTTP Link header), enforce full absolute HTTPS canonicals, and maintain symmetrical return tags on every linked page.

Over half of multilingual websites silently break their own hreflang clusters through one missing return link, a wrong underscore (de_DE), or a trailing-slash mismatch between /de and /de/. This practical hreflang implementation tutorial and audit guide shows all three supported methods, exact ISO code tables, and how to validate live tags in seconds.

The 3 Valid Ways to Implement Hreflang

Google and Yandex support three equivalent deployment methods. Pick one primary method per URL set to prevent conflicting signals:

Place the full bidirectional set inside <head> on every language version, including a self-referencing tag pointing to the current page itself plus x-default:

<link rel="alternate" hreflang="en" href="https://www.example.com/pricing" />
<link rel="alternate" hreflang="de-DE" href="https://www.example.com/de/preise" />
<link rel="alternate" hreflang="de-AT" href="https://www.example.com/at/preise" />
<link rel="alternate" hreflang="de-CH" href="https://www.example.com/ch/preise" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/pricing" />

For stores with thousands of SKUs, moving hreflang into sitemap.xml keeps HTML payload slim and centralizes validation:

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

3. HTTP Response Headers (Best for Non-HTML Assets Like PDFs)

Use the Link: HTTP header when serving localized whitepapers or specification PDFs that lack an HTML <head>.

Correct ISO 639-1 Language & ISO 3166-1 Region Codes

Target AudienceValid Hreflang CodeInvalid Code (Ignored by Google)
Global Englishenen_US (underscore)
United Kingdom (GBP)en-GBen-UK or uk
German (All Countries)deger or de-EU
Germany Specificde-DEde_DE
Austria Specificde-ATat (country alone is invalid!)
Switzerland (German)de-CHch or de-SW
Switzerland (French)fr-CHfr_CH
Denmark / Swedenda-DK / sv-SEdk / se (country codes!)
Unmatched Fallbackx-defaultdefault

The 7 Most Common Hreflang Errors (And How to Check Them)

  1. Missing Reciprocal Return Tags: If Page A points to Page B, Page B must point back to Page A. One-way links invalidate the pair.
  2. Missing Self-Reference: Every page must list its own canonical URL in its own hreflang block.
  3. Canonical vs. Hreflang Conflict: Never point an hreflang tag to a redirected URL (301/308), a noindex page, or a URL whose rel="canonical" points somewhere else.
  4. Trailing-Slash Mismatch (/de vs. /de/): Ensure hreflang URLs, canonicals, and sitemap.xml match your exact live redirect rule character-for-character.
  5. Underscores Instead of Hyphens: Always write de-CH, never de_CH.
  6. Relative URLs: Always declare full absolute https://... URLs—never href="/de/preise".
  7. Omitting x-default: Always assign x-default to your global fallback or language selector so searchers outside mapped regions land cleanly.

Check & Generate Valid Hreflang Tags Instantly

  • Browser Checker & Generator: Validate pasted <link rel="alternate" hreflang="..."> blocks or generate clean tags alongside Google snippet pixel widths in our SERP Snippet Checker & Hreflang Tool.
  • Command-Line Audit: Run curl -sS https://www.yourdomain.com/de | npx hreflang-serp-lint --json to audit live HTML in seconds.

Open the Live Hreflang & SERP Snippet Checker → | Read our Next.js App Router i18n Guide →

Quick Answers & FAQ

Frequently Asked Questions

Do hreflang tags require a self-referencing link on every page?

Yes. Every page in an hreflang cluster must include an alternate tag pointing to its own canonical URL alongside all sibling language URLs and x-default. Omitting the self-reference can cause search engines to drop the cluster.

Should I use HTML hreflang tags or XML sitemap hreflang?

Google treats HTML <link>, HTTP Link headers, and XML sitemap xhtml:link annotations equally. Use HTML tags for small-to-medium marketing sites and Next.js apps, XML sitemaps for large catalogs with thousands of SKUs, and HTTP headers for non-HTML PDFs.

What happens when a return hreflang tag is missing?

Hreflang annotations must be reciprocal. If your English page references /de/preise, then /de/preise must reference the English URL back; otherwise Google ignores the unconfirmed link to prevent unauthorized cross-site targeting.

Is hreflang="de_CH" or hreflang="ch" valid for Switzerland?

No. Hreflang requires BCP-47 hyphenated ISO codes with language first and optional region second. Use de-CH for Swiss German, fr-CH for Swiss French, and de-AT for Austria—never underscores or standalone country codes.

Run Related Free Browser Checkers Now

Recommended Tools for This Playbook

Explore More How-To Guides

View All Playbooks →
Free Check · 200+ Element /de/ Health Preview PDF & Excel / CSV Report
Checks repeated words, DIN 5008 spacing, readability friction, English text leaks & Datenschutz mapping—emailed free as a 2-page PDF + spreadsheet.
Book $400 24h Fix →