How to Fix Hreflang Tags: Add Self-References and x-default

Your site declares hreflang language alternates, but some pages are missing either a tag that points to the page itself or an x-default fallback. By the end of this guide, every translated or regional page will carry a complete, reciprocal hreflang set that includes itself, all its siblings and an x-default, with URLs that match the page's final address exactly.

By Updated ⏱ 1-3 hours depending on the number of templates🎯 Intermediate● Medium impactOn-Page
Illustration: Hreflang for multilingual pages fix guide
ON-PAGE · FIX GUIDE Hreflang for multilingual pages IMPACTEFFORT TIME1-3 hours depending on the number of templates LEVELIntermediate

Why it matters

Google treats hreflang as a cluster. If a page doesn't list itself, or the URLs in the cluster don't match the addresses Google actually indexes, the annotations can be ignored. The result is the wrong version ranking in a market, such as US prices shown to UK searchers or English pages appearing in German results.

That costs clicks and conversions, and it can cause duplicate-content confusion between near-identical regional pages. The x-default tag tells search engines and AI answer engines which URL to use for visitors who match none of your declared locales, so they don't land on an arbitrary version.

✕Beforehttps://example.com/de/preise/ has<link rel="alternate" hreflang="en"href="https://example.com/pricing/">✓Afterhttps://example.com/de/preise/ listshreflang="de" (itself), hreflang="en"(https://example.com/pricing/) and

What you need

Access to your theme templates, CMS multilingual plugin settings, or framework code
A list of every language/region version and its URL
A terminal with curl, or browser DevTools, to check final URLs after redirects
Google Search Console access for the property (optional, for post-fix monitoring)

Step-by-step fix

1

Map every page into its language cluster

Build a spreadsheet with one row per piece of content and one column per locale. For example, row "Pricing" has columns en, de and fr-CA, each holding that version's URL. Decide which URL is your x-default: usually the language-selector page or your main international version.

Pages without a translation simply leave that cell blank. Do not point a locale at an unrelated page.

text
content,en,de,fr-ca,x-default
pricing,https://example.com/pricing/,https://example.com/de/preise/,https://example.com/fr-ca/tarifs/,https://example.com/pricing/
home,https://example.com/,https://example.com/de/,https://example.com/fr-ca/,https://example.com/
Pro tip: Use ISO 639-1 language codes (en, de) and optional ISO 3166-1 Alpha-2 region codes (en-GB, fr-CA). "en-UK" is invalid; use en-GB.
2

Confirm the exact final URL of each version

The self-reference must match the page's final address character for character, after any redirects. That includes https vs http, www vs non-www, the trailing slash and query strings. Run curl against each URL and take the last Location value, or the original URL if there is no redirect.

Put those final URLs in your spreadsheet.

text
curl -sIL https://example.com/de/preise | grep -iE '^(HTTP|location)'
# HTTP/2 301
# location: https://example.com/de/preise/
# HTTP/2 200   <- use https://example.com/de/preise/ in hreflang
Pro tip: Use the same URL in hreflang as in your rel="canonical". If hreflang points to a URL that canonicalises or redirects elsewhere, Google ignores that annotation.
3

Write the full hreflang block, including self and x-default

Each page in a cluster gets the same block in its <head>. It lists every version, including the page itself, plus one x-default. Use absolute URLs.

The block is identical across siblings, which is what makes it reciprocal.

html
<!-- Same block on /pricing/, /de/preise/ and /fr-ca/tarifs/ -->
<link rel="alternate" hreflang="en" href="https://example.com/pricing/" />
<link rel="alternate" hreflang="de" href="https://example.com/de/preise/" />
<link rel="alternate" hreflang="fr-CA" href="https://example.com/fr-ca/tarifs/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing/" />
Pro tip: x-default can share a URL with another locale. Pointing both en and x-default at the English page is valid and common.
4

Generate the tags from a template, not by hand

Hard-coded tags drift as soon as someone adds a page. Output the block from your page template using the translation map your CMS already stores. The loop must include the current page's own locale.

Skipping it is the most common cause of a missing self-reference.

php
<?php
// $translations = ['en' => 'https://example.com/pricing/', 'de' => 'https://example.com/de/preise/', 'fr-CA' => 'https://example.com/fr-ca/tarifs/'];
foreach ($translations as $lang => $url) {
  printf('<link rel="alternate" hreflang="%s" href="%s" />' . "\n", esc_attr($lang), esc_url($url));
}
$default = $translations['en'] ?? reset($translations);
printf('<link rel="alternate" hreflang="x-default" href="%s" />' . "\n", esc_url($default));
?>
Pro tip: Build URLs from the same function that outputs your canonical tag. That way trailing slashes and protocol always match.
5

Remove conflicting or duplicate hreflang sources

Check that only one system outputs hreflang. Theme code, a multilingual plugin, an SEO plugin and an XML sitemap can all add annotations, and they often disagree. Keep the tags in the HTML <head> as your primary method.

Delete stray hard-coded blocks left over from older themes.

  • Search templates for hreflang to find hard-coded copies
  • If you also use sitemap hreflang, generate it from the same data so URLs match
text
grep -rn "hreflang" ./wp-content/themes/ ./templates/ ./app/ 2>/dev/null
Pro tip: Sitemap-only hreflang is valid for Google, but on-page tags are easier to audit and are visible to every crawler that fetches the page.
6

Recheck redirects and canonicals on each locale

Load each version and confirm three things: it returns 200, its canonical points to itself, and its hreflang self-reference uses that same URL. A locale page that canonicalises to the English version breaks the cluster even when the tags look correct.

text
curl -s https://example.com/de/preise/ | grep -iE 'rel="(canonical|alternate)"'
7

Verify the result across the cluster

View source on at least one page per template and locale. Confirm the block contains the page's own URL and an x-default line. Then rerun the site audit; the check should pass once every page that declares hreflang has both.

Over the following weeks, watch Search Console for indexing changes per locale.

text
curl -s https://example.com/fr-ca/tarifs/ | grep -io 'hreflang="[^"]*" href="[^"]*"'
Pro tip: Test URLs with and without a trailing slash. If both return 200 instead of one redirecting, pick one, redirect the other and use the redirect target in hreflang.

Platform-specific notes

WordPress

Yoast SEO and Rank Math do not create hreflang on their own; the multilingual plugin does. With WPML, check WPML > Languages > SEO Options and enable "Display alternative languages in the HEAD section". With Polylang, hreflang is output automatically, but x-default handling depends on your URL setup and version, so view source to confirm it appears. Remove any manual hreflang code from header.php or functions.php to avoid duplicates.

Shopify

Shopify Markets outputs hreflang for published languages and markets, including x-default, through content_for_header. Duplicates usually come from older themes or translation apps that hard-code <link rel="alternate"> in theme.liquid. Remove those, then publish each language in Settings > Languages and assign markets in Settings > Markets.

Next.js

In the App Router, set alternates in generateMetadata. For example: alternates: { canonical: 'https://example.com/de/preise/', languages: { en: 'https://example.com/pricing/', de: 'https://example.com/de/preise/', 'x-default': 'https://example.com/pricing/' } }. Include the current locale in languages. Make sure the trailingSlash setting in next.config.js matches the URLs you list.

Webflow

Webflow Localization adds hreflang tags automatically for enabled locales, controlled in Site settings > Localization. If you add custom hreflang in Page settings > Custom code, remove it so it doesn't conflict. Check the published source, not the Designer, to confirm the self-reference and x-default are present.

Wix

Wix Multilingual outputs hreflang including x-default automatically. You can't edit the tags directly, so fixes are usually about consistency. Connect your domain so each language uses one stable URL format (subdirectory or subdomain under Settings > Multilingual), and remove any custom hreflang added via Settings > Custom code or SEO > Advanced SEO tags.

Check that it worked

✅ How to verify

  • View source on one page per locale and confirm it has a <link rel="alternate" hreflang> whose href exactly equals the page's address bar URL, plus a hreflang="x-default" line.
  • Run curl -sIL on every hreflang href and confirm each returns HTTP 200 with no redirect hop.
  • Rerun the site audit and confirm the hreflang check reports no pages lacking a self-reference or x-default.
  • Crawl the site with an SEO crawler's hreflang report (e.g. Screaming Frog > Hreflang tab) to catch missing return links and non-200 targets.

⚠️ Common mistakes

  • Listing only the other languages and leaving out the current page, so no tag in the block points to the page itself.
  • Using a self-reference URL that differs from the final URL, such as http vs https, a missing trailing slash, or a URL that redirects.
  • Adding x-default on the main language page only instead of including it in the block on every version.
  • Using invalid codes like en-UK or es-LA, or pointing hreflang at pages whose canonical points to a different locale.

Is this still an issue on your site? Run a free audit — ZORO checks this and 294 other SEO, AI-visibility, accessibility and security signals, with fixes for your platform.

Check my site free

FAQ

Does every hreflang page need a self-referencing tag?

Yes. Google's documentation says each language version should list itself as well as all other versions. Without the self-reference, the cluster is incomplete and annotations may be ignored.

Is x-default required for hreflang?

It isn't strictly required by Google, but it is strongly recommended. It defines the fallback for users who match none of your locales, and this audit treats it as required. Point it at your language selector or main international page.

Should hreflang URLs match the canonical URL?

Yes. Each hreflang href should be the indexable, canonical, 200-status URL of that version. If it redirects or canonicalises elsewhere, search engines drop that annotation.

Should I use HTML tags, HTTP headers or the XML sitemap for hreflang?

All three are valid for Google, but use only one method per URL set. HTML <head> tags suit most sites. HTTP Link headers suit non-HTML files like PDFs. Sitemaps suit very large sites where adding tags to templates is impractical.