How to set up hreflang tags in WordPress

To set up hreflang in WordPress, give every language or regional version of a page its own URL, then output a set of <link rel="alternate" hreflang="..."> tags on each version that lists all versions, including itself, plus an x-default. WordPress core does not output hreflang. In practice a multilingual plugin such as WPML or Polylang generates the tags from the translations you link together, and your job is to configure it correctly and check the output.

hreflang tells Google which version to show to which searcher. It does not translate anything, it does not combine rankings, and it is ignored if the tags on different pages disagree with each other.

Step by step

1. Choose a URL structure

Pick one structure and use it everywhere:

StructureExampleNotes
Subdirectoriesexample.com/fr/One domain, simplest to run on one WordPress install
Subdomainsfr.example.comSeparate hosting possible
Country domainsexample.frStrongest local signal, most to maintain

Never serve different languages at the same URL based on the visitor's browser language or IP. Googlebot mostly crawls from the US and would only see one version.

2. Use the right codes

The value is a language code in ISO 639-1, optionally followed by a region in ISO 3166-1 alpha-2: en, fr, en-gb, en-us, pt-br. Common mistakes:

  • en-uk is wrong. The region code for the United Kingdom is gb.
  • A region alone, like us, is invalid. The language always comes first.
  • Use a region only when you have genuinely different versions for different countries. A single English version needs only en.

3. Configure your multilingual plugin

In WPML or Polylang, set the language list, URL format and default language, then connect each translation to its source post. Both plugins output hreflang tags for connected translations automatically. Check their language settings for the locale used for each language so the output matches the codes you chose. A post with no linked translation gets no alternate tags, so untranslated pages are a common gap.

4. Make every set complete and reciprocal

Each version must list every version, including itself. If the English page points to the French page, the French page must point back. A one-way pair is ignored.

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

The same four lines appear on all three pages. Use absolute URLs that return 200 and are not redirected. If you need to build a set by hand, the hreflang tag generator produces it with x-default included.

5. Add x-default

x-default names the page for searchers whose language you do not serve, often your main language version or a language picker page. It is optional but recommended. WPML and Polylang can add it; check that it points where you expect.

6. Keep canonicals self-referencing

Each language version should carry a canonical pointing to itself, not to the English original. A French page with a canonical to the English page tells Google the French page is a duplicate, and the hreflang set breaks. If you use Hydrogen SEO alongside a multilingual plugin, its default self-referencing canonical is what you want; view source on a translated page to confirm the canonical and the hreflang tags agree.

7. Check the live output

View source on two or three pages in each language and confirm the full set is present and identical. Then check a URL from each language in Search Console's URL Inspection tool: the Google-selected canonical should be the URL you inspected. If Google picks the other language as canonical, the pages are probably too similar, for example an untranslated copy.

Common hreflang mistakes

  • Pointing at redirects or noindexed pages. Every URL in the set must be indexable.
  • Untranslated copies. Machine-duplicated English content on /fr/ is a duplicate, and hreflang does not fix that.
  • Mixing http and https or www and non-www across the set.
  • Two plugins printing hreflang. Check the source for duplicate sets after installing any SEO or translation add-on.

Alternatives to head tags

hreflang can also go in HTTP headers, useful for PDFs, or in the XML sitemap with xhtml:link entries. Use one method per page. For most WordPress sites, the head tags from the multilingual plugin are the easiest to maintain.

Common questions

Does Hydrogen SEO output hreflang tags?

No. Use your multilingual plugin, such as WPML or Polylang, for hreflang. Hydrogen SEO's self-referencing canonicals work alongside it.

Do I need hreflang if I only have one language?

No. hreflang is only for sites with multiple language or regional versions of the same content.

Is x-default required?

No, but it is recommended. It tells Google which page to show searchers whose language or region none of your versions target.