Skip to content

WordPress hreflang for multilingual sites — getting it right

Hreflang on a multilingual WordPress site fails in subtle ways — self-referencing, x-default, return tags. Diagnostic commands and the patterns that hold.

Hreflang tells search engines that two URLs are translations of each other. On a WordPress site with WPML, Polylang, or TranslatePress, the multilingual plugin is supposed to emit hreflang automatically. It usually does — but with predictable mistakes: missing self-referencing tags, no x-default, return-tag mismatches between language pairs, and orphaned tags pointing at deleted translations. Search Console’s “International Targeting” report flags these, but the operational fix requires touching the multilingual plugin’s config.

What’s happening

Hreflang tags appear in the <head> as <link rel="alternate" hreflang="fr-CA" href="https://example.com/fr/page/">. For a translation set to be valid, each URL must include hreflang tags pointing at every translation including itself, plus optionally an x-default for the language picker page. The hreflang values use ISO 639 language codes (or language-region like en-US, fr-CA). On WordPress, the multilingual plugin owns the linkage between translated posts — if that linkage breaks (deleted translation, draft status, taxonomy mismatch), the hreflang tags become stale.

How to verify

From any host with curl:

curl -s https://example.com/en/some-page/ | grep -i 'rel="alternate".*hreflang'
curl -s https://example.com/fr/page-en-francais/ | grep -i 'rel="alternate".*hreflang'
curl -s https://example.com/en/ | grep -i 'hreflang="x-default"'

For a page with three languages (English, French, Spanish), you should see four link rel="alternate" tags per page: one for each language plus x-default. The English page should reference itself, the French and Spanish translations, and the default. The French page should reference the same set, including itself.

From WP-CLI:

wp post list --post_status=publish --field=ID --post_type=post | head -5 | xargs -I{} wp eval "var_dump(apply_filters('wpml_post_language_details', null, {}));"
wp plugin list --status=active --field=name | grep -iE 'wpml|polylang|translatepress|multilingual'

The fix

  1. Self-referencing tags. Each translated URL must include a hreflang tag pointing at itself. If you only see tags for the other languages, the multilingual plugin’s hreflang module is misconfigured. WPML: Languages > SEO Options > self-referencing on. Polylang: Settings > Languages > URL modifications.

  2. x-default for the language picker. If your site has a / root that serves a language picker (or auto-redirects based on Accept-Language), point x-default at it. If / is the default language (typically English), x-default should point at the same URL as the English version. Add manually if the plugin doesn’t:

    <link rel="alternate" hreflang="x-default" href="https://example.com/" />
  3. Return-tag mismatches. If page A (English) declares page B (French) as alternate, page B must declare A as alternate. This is the most common hreflang error. Multilingual plugins handle this automatically when posts are linked — but if you have orphan translations (French post created without a linked English original), the tags only point one way. Audit in WPML: WPML > Translation Management > look for posts marked “Not connected.”

  4. Cross-domain hreflang. If translations live on separate domains (example.com and example.fr), hreflang still works — but both domains must be in the same Search Console account, and the hreflang URLs must be absolute. WPML supports this via “different domains per language” mode.

  5. Don’t mix WordPress URL structures. Hreflang tags must point at the canonical URL of the translation. If your French version uses /fr/page/ and the English uses /page/?lang=en (query param), hreflang gets confusing. Pick subdirectory or subdomain consistently for all languages. Stack Harbor’s enterprise WordPress hosting baseline uses subdirectories (/fr/, /es/) for new multilingual sites.

  6. Validate with Search Console. Search Console > Legacy tools and reports > International Targeting > Language. This report flags missing return tags, unknown language codes, and other errors. Run it monthly on multilingual WordPress sites.

  7. Region targeting (optional). hreflang="fr-CA" targets French speakers in Canada specifically. Only use region targeting if you have region-specific content (different pricing, different shipping, different legal text). Otherwise use language-only (hreflang="fr") to avoid splitting authority across regional variants.

  8. Maintenance after content changes. When a translation is deleted, the multilingual plugin should clean up hreflang references on the remaining translations. Test by deleting a translation in staging, then checking the rendered <head> of the remaining ones.

Stack Harbor handles hreflang configuration as part of enterprise WordPress hosting multilingual rollouts. Start the conversation when your WordPress site serves the wrong language in search results.