返回博客
HREFLANG GUIDE

Hreflang Guide: Syntax, Mistakes, and Best Practices

Hreflang is the single most error-prone part of multilingual SEO. Get it right and your locale-specific pages rank in their target regions. Get it wrong and Google silently ignores your alternates — your Chinese page shows to US searchers, your English page ranks in Hong Kong, and your traffic tanks without a clear ranking drop. This guide covers syntax, common mistakes, testing, and best practices for 2026.

What hreflang is and why it matters

Hreflang (also called 'rel=alternate hreflang') is an HTML link attribute that tells search engines which language and region version of a page to show in which searchers' results. It was introduced by Google in 2011 to solve the duplicate-content problem multilingual sites face: if you have an English page and a Spanish page with the same content, Google may treat one as a duplicate of the other and only index one. Hreflang tells Google 'these are intentional alternates for different audiences — index both and route searchers appropriately.'

Without hreflang, a US searcher querying 'plumber near me' might see your Spanish page (because Google thinks it's relevant to their query) — and bounce because they don't read Spanish. With correct hreflang, Google shows your English page to the US searcher and your Spanish page to a Mexico searcher. The result: better engagement, higher conversion, and no cannibalization between locales.

Hreflang matters most for: multilingual service businesses (immigrant communities, cross-border professionals), international ecommerce, and any site publishing the same content in multiple languages. If your site is single-locale, hreflang is unnecessary — Google handles it correctly without the attribute.

Hreflang syntax: the spec

Hreflang uses the link rel=alternate attribute with an hreflang value. The value combines an ISO 639-1 language code with an optional ISO 3166-1 alpha-2 region code. Examples: en (English, any region), en-US (English United States), zh-CN (Chinese Simplified, Mainland China), zh-TW (Chinese Traditional, Taiwan), es-MX (Spanish Mexico), fil-PH (Filipino Philippines).

Critical: region codes are case-sensitive. zh-CN is correct; zh-cn or zh-cN are not. Google ignores incorrect casing silently. Always use uppercase region subtags per the ISO standard.

A complete hreflang implementation requires three pieces on every page: (1) a self-referential hreflang tag (the page declaring its own locale), (2) an hreflang tag for every other locale version (the alternates), and (3) an x-default tag pointing to the locale to show when no alternate matches the searcher. Missing any of these breaks the implementation.

Every alternate must be bi-directional. If page A (English) declares page B (Chinese) as its alternate, page B must declare page A as its alternate. Missing return tags is the most common hreflang mistake — Google ignores both directions when one is missing.

The 7 most common hreflang mistakes (and how to fix them)

Mistake 1 — Wrong locale code casing. zh-cn instead of zh-CN, fil-ph instead of fil-PH. Google ignores incorrectly-cased tags silently. Fix: always uppercase region subtags.

Mistake 2 — Missing return tags. Page A declares page B as alternate, but page B doesn't declare page A. Fix: every alternate must be bi-directional; if you add a new locale, update all existing pages to declare it back.

Mistake 3 — Missing or wrong x-default. Without x-default, Google guesses which locale to show unmatched searchers; usually it picks your most-indexed locale, which may not be what you want. Fix: explicitly declare x-default (usually pointing to your primary business locale).

Mistake 4 — Hreflang URLs that don't match canonical URLs. If /pricing has canonical /pricing, but its hreflang points to /pricing?utm_source=internal, Google ignores the alternate. Fix: hreflang URLs must match canonical URLs character-for-character.

Mistake 5 — Hreflang on noindex or canonicalized-away pages. Pages blocked from indexing should not declare hreflang. Fix: omit hreflang tags on noindex routes, redirected routes, and pages canonicalized to other URLs.

Mistake 6 — Hreflang to soft-404 or 'locale not available' pages. Don't declare an alternate URL that returns a 'sorry, this page isn't available in your language' message — that's a soft 404 and Google penalizes both directions. Fix: only declare alternates that contain real content; if a page doesn't exist in a locale, don't declare that locale as alternate.

Mistake 7 — Inconsistent locale variants across pages. Page A declares locales en, zh-CN, es, but page B declares only en and zh-CN. Inconsistency confuses Google. Fix: every page that exists in multiple locales should declare all locales where it exists — and no locales where it doesn't.

How to test your hreflang implementation

Step 1 — Inspect the rendered HTML. View source on any multilingual page and check the head section for link rel=alternate tags. You should see one self-referential tag, one tag per alternate locale, and one x-default tag. Verify casing, URL matching, and bi-directional tags.

Step 2 — Google Search Console. Under International Targeting > Country, Google reports hreflang errors it finds on your site. Common errors: missing return tags, wrong locale codes, broken alternate URLs. Fix every error Google reports.

Step 3 — Ahrefs or Sitebulb crawl. These tools detect hreflang issues at scale — bi-directional tag mismatches across thousands of pages, broken alternates, incorrect locale codes. Run a full-site crawl quarterly.

Step 4 — Manual SERP test. Search for your brand name from different locale-specific devices (use a VPN or Google's country-specific domains like google.com.hk for Hong Kong) and verify the right locale version shows. If you see locale cannibalization (wrong version ranking in wrong region), hreflang is likely the cause.

Step 5 — Check indexing in Search Console. Use URL Inspection on each locale version of a page to confirm Google has indexed all alternates. If a locale version isn't indexed, hreflang isn't passing the signal correctly.

Hreflang best practices for 2026

Best practice 1 — Use language-only codes (en, zh, es) when you don't have region-specific content. Use region codes (en-US, en-GB, zh-CN, zh-TW) only when content genuinely differs by region (currency, legal references, vocabulary). Over-specifying region codes when content is identical creates unnecessary alternates.

Best practice 2 — Set x-default to your primary business locale (usually the locale of your company's home country). For a US business, x-default = en or en-US. For a Chinese business with an English version, x-default = zh-CN if your primary audience is Chinese, en if international.

Best practice 3 — Generate hreflang from a single source of truth (your CMS or website builder). Hand-maintaining hreflang across thousands of pages guarantees drift. Cogo Site, WordPress + WPML, and Shopify's multilingual features all auto-generate hreflang; choose a builder that does.

Best practice 4 — Keep hreflang URLs clean and stable. Don't include query parameters, session IDs, or tracking parameters in hreflang URLs. Once an alternate URL is published, don't change it without a redirect — Google's hreflang cache takes weeks to rebuild.

Best practice 5 — Audit hreflang after every locale launch, locale removal, or major content migration. Drift happens; hreflang is the canary in the coal mine for multilingual site health.

How Cogo Site implements hreflang correctly

Cogo Site generates hreflang from a single source of truth — the locale-prefixed URL routing. Every page automatically includes self-referential, alternate, and x-default tags with correct ISO casing, bi-directional return tags, and canonical-matching URLs. You don't write the tags; you don't maintain them.

Adding a locale regenerates hreflang across all pages atomically — there's no window where existing pages are missing the new alternate. Removing a locale cleanly strips hreflang to that locale from all pages, preventing soft-404s.

Per-page locale visibility lets you mark a page as English-only or Chinese-only — hreflang only declares alternates where both exist, preventing the 'soft-404 alternate' mistake.

The x-default locale is configurable per site, defaulting to the original publishing locale. Hreflang URLs are derived from the same routing as canonical URLs, so they cannot drift.

Hreflang quick-reference checklist

  • Every multilingual page has self-referential + alternate + x-default tags
  • Locale codes use uppercase region subtags (zh-CN, not zh-cn)
  • All alternates are bi-directional (page A declares page B and vice versa)
  • Hreflang URLs match canonical URLs character-for-character
  • x-default points to the locale to show unmatched searchers
  • No hreflang on noindex, redirected, or canonicalized-away pages
  • No hreflang to soft-404 or 'locale not available' pages
  • Locale variants are consistent across all pages (no missing locales)

Frequently asked questions

What is hreflang and what does it do?

Hreflang is an HTML link attribute (rel=alternate hreflang) that tells search engines which language and region version of a page to show in which searchers' results. Without hreflang, Google may show the wrong locale version to the wrong searcher — e.g., your Spanish page to an English-speaking searcher — causing bounces and lost rankings. With correct hreflang, each locale version ranks for its target audience. Hreflang is essential for any multilingual site publishing the same content in multiple languages.

How do I write hreflang tags correctly?

Each multilingual page needs three pieces in its head section: (1) a self-referential hreflang tag declaring the page's own locale (e.g., hreflang='en-US'), (2) an hreflang tag for every other locale version (e.g., hreflang='zh-CN' href='/zh-CN/pricing'), and (3) an x-default tag pointing to the locale to show unmatched searchers (e.g., href='https://example.com/pricing' hreflang='x-default'). All alternates must be bi-directional — if A declares B, B must declare A. Locale codes must use uppercase region subtags (zh-CN, not zh-cn).

What are the most common hreflang mistakes?

The top mistakes: (1) wrong locale code casing (zh-cn instead of zh-CN), (2) missing return tags (A declares B but B doesn't declare A), (3) missing or wrong x-default, (4) hreflang URLs that don't match canonical URLs, (5) hreflang on noindex pages, (6) hreflang to soft-404 or 'locale not available' pages, and (7) inconsistent locale variants across pages. Any of these silently breaks the implementation — Google ignores incorrect hreflang without telling you. Cogo Site generates hreflang correctly by construction; mainstream solutions like WordPress + WPML require careful maintenance to avoid these mistakes.

How do I test if my hreflang is correct?

Five steps: (1) inspect rendered HTML for self-referential + alternate + x-default tags, (2) check Google Search Console's International Targeting report for errors, (3) run a full-site crawl with Ahrefs or Sitebulb to detect bi-directional mismatches at scale, (4) test SERPs manually using country-specific Google domains (google.com.hk, google.com.mx), and (5) verify URL Inspection in Search Console confirms each locale version is indexed. If a locale version isn't indexed or wrong versions rank in wrong regions, hreflang is the likely cause.

Does hreflang help with Baidu and Bing, or just Google?

Hreflang is honored by Google, Bing, and Yandex. Baidu has historically been less consistent with hreflang — it reads the tags but may take longer to act on them, and Baidu's crawler is slower to discover new alternates. For Baidu specifically, also submit a Chinese sitemap via Baidu Webmaster Tools and ensure correct locale-prefixed URL routing. Cogo Site emits sitemaps and hreflang that work across all four search engines; mainstream CMSs like WordPress with WPML produce correct hreflang but require sitemap configuration per locale.

Stop debugging hreflang by hand

Cogo Site generates every hreflang tag correctly, on every page, in every locale. Free to start — no card required.

Related multilingual resources

我们使用 Cookie

我们使用 Cookie 来提升您的浏览体验并分析网站流量。点击"接受"即表示您同意我们使用 Cookie。 了解我们的 Cookie 政策