ArticleMultilingual SEO

Hreflang in WordPress: how plugins print it and how to check

Where hreflang comes from on WordPress, what WPML, Polylang, TranslatePress and Weglot print by default, how Yoast SEO and Rank Math fit in, and how to check.

Published
Reading time
7 min read
Neighbours sit around a fire under green northern lights, on a round bench laid with green and orange leaf tiles.
On this page
  1. Who prints what on a multilingual WordPress site
  2. What each translation plugin prints by default
  3. A correct result, in one example
  4. How to check hreflang on a WordPress site
  5. Common hreflang mistakes on WordPress
  6. How LangRelay does it on WordPress

On a WordPress site, hreflang comes from your translation plugin. WordPress itself runs a site in one language, which it prints as the lang attribute, and has no idea that /fr/rooms/ is the French version of /rooms/. WPML, Polylang, TranslatePress, Weglot and LangRelay each add the tags for the languages they manage, with different defaults for x-default and for sitemaps. Yoast SEO and Rank Math look after titles, descriptions, canonicals and the sitemap, and the translation plugin adds hreflang to them. To check the result, open a translated URL's source and compare its hreflang set, canonical and lang with the original's.

Who prints what on a multilingual WordPress site#

Three pieces of software write into the <head> of a translated page:

Output

Usually printed by

<html lang="...">

The theme, through WordPress's language_attributes(), unless the translation plugin changes it

<title>, meta description, Open Graph tags

The SEO plugin, or the theme and WordPress core without one

<link rel="canonical">

The SEO plugin, or WordPress core

<link rel="alternate" hreflang="...">

The translation plugin

Sitemap entries with xhtml:link alternates

The translation plugin, inside the SEO plugin's sitemap, where it supports that

Yoast's help center says Yoast SEO adds canonical URLs to a WordPress site, and that its wpseo_canonical filter can change them or remove the tag. On the hreflang side, WPML's documentation for its Yoast SEO and Rank Math integration says the hreflang tags and the language-aware sitemaps come from WPML core, and Rank Math's own knowledge base says WPML adds the hreflang to translated pages. In both cases the SEO plugin owns the canonical and the translation plugin owns the hreflang.

What each translation plugin prints by default#

This is what each vendor's documentation said on 2026-10-06. Where a cell says the documentation does not cover it, check the plugin's output on your own site rather than assuming either way.

Plugin

Hreflang in the head

x-default

Hreflang in sitemaps

How to adjust

WPML

One tag per language on every page

Added, for visitors whose language matches no translation

Inside Yoast SEO and Rank Math sitemaps

WPML's settings for URLs, slugs and SEO

Polylang

Automatic, in free Polylang too: its hreflang article says it "automatically uses the hreflang HTML tag attributes"

Only on the home page when it is auto-redirected to a language home page

Not covered in the pages checked

The pll_rel_hreflang_attributes filter changes the list, for example to add x-default on every page or to replace en with en-GB

TranslatePress

A tag on every page for every language you add

An Advanced setting, "Enable the hreflang x-default tag for language"

With the SEO Pack add-on, which needs a premium version (Personal, Business or Developer), it extends the sitemaps of SEO plugins into a multilingual sitemap

The trp_hreflang filter changes the code printed for a language, for example fr-CH for the language TranslatePress stores as fr_FR

Weglot

Added automatically to the <head> of your pages

Not added by default

Its WordPress help says the head tags mean you don't need to edit your sitemap by hand; it does not say it writes hreflang into sitemaps

The weglot_href_lang filter, for example to add x-default

LangRelay

Printed on the original and every translated version

Always the original page's URL

None

The set follows what has been approved and published

The defaults differ because the vendors read Google's guidance on x-default differently, which the article on self-referencing hreflang and x-default goes into. If you switch translation plugin, check x-default afterwards: it may change with the plugin without anyone deciding it should.

WPML prints hreflang in the head and inside the sitemaps of Yoast SEO and Rank Math, and its WPML SEO add-on, included with the Multilingual CMS and Agency plans, carries those plugins' fields into translations. Polylang's filter lets a developer reshape the whole list in a few lines of code. TranslatePress puts x-default behind a switch a site owner can set without code. Weglot's WordPress help explains when x-default is worth adding and gives the filter to add it. LangRelay's set needs no configuration, but it has no sitemap output and no way to point x-default anywhere but the original.

A correct result, in one example#

A small hotel's WordPress site is in English, with French and German translations under /fr/ and /de/. This is what the head of the French rooms page should contain once the plugins have done their work, with the lines that matter for hreflang:

<html lang="fr">
<head>
  <title>Nos chambres | Orchard Inn</title>
  <link rel="canonical" href="https://www.orchardinn.example/fr/rooms/">
  <link rel="alternate" hreflang="en" href="https://www.orchardinn.example/rooms/">
  <link rel="alternate" hreflang="fr" href="https://www.orchardinn.example/fr/rooms/">
  <link rel="alternate" hreflang="de" href="https://www.orchardinn.example/de/rooms/">
  <link rel="alternate" hreflang="x-default" href="https://www.orchardinn.example/rooms/">
</head>

The title is in French, the canonical names the French URL, lang says French, and the alternate set is the one that also appears on the English and German rooms pages. Whether x-default is present depends on the plugin, as the table above shows.

How to check hreflang on a WordPress site#

WPML's documentation gives the first step: open a translated URL, view the source, and search for hreflang. From a terminal you can see the HTML exactly as your server sends it, before any script runs:

curl -s https://www.orchardinn.example/fr/rooms/ \
  | grep -iE 'hreflang|rel="canonical"|<html'

Then work through this list, on the original and on one translated page per language:

  1. One set only. Each language should appear once. Two fr lines usually mean two plugins are printing sets, for example an old translation plugin left active after a switch.
  2. The set is identical on every version and includes the page itself. Google asks for both, and ignores a pair that does not point both ways.
  3. The codes use a hyphen, not an underscore. WordPress locales are written fr_FR; an hreflang value is fr or fr-FR.
  4. The canonical on the translated page names the translated URL. If it names the English page, read hreflang and canonical tags before changing anything.
  5. lang on the translated page is the translated language. A French page with lang="en-US" is a sign the plugin left the theme's value alone; hreflang vs the HTML lang attribute explains why that still matters.
  6. Every URL in the set answers 200, without a redirect and without noindex.
  7. If your plugin puts hreflang in the sitemap, open the sitemap and find one translated URL's entry. The article on hreflang in XML sitemaps shows what a valid entry looks like.

If you use a page cache, clear it after you change a translation plugin's settings and fetch the page again before you trust what you see.

Common hreflang mistakes on WordPress#

Mistake

How it shows

Fix

Two plugins print sets

Duplicate lines per language, sometimes with different URLs

Deactivate the one you no longer use, then check again

The SEO plugin's canonical names the original on translated pages

Google may index the original in place of the translation

Let the translation plugin manage the canonical on translated URLs

A manual hreflang snippet in the theme

A static set that does not change when a language goes live

Remove it and let the plugin generate the set

Untranslated pages listed as translations

A searcher lands on English text under /fr/

List a language only once that page is translated; does machine translation hurt SEO? covers when a translation is ready

lang still the site language

Screen readers and browsers treat French text as English

Use a plugin that sets lang per language

How LangRelay does it on WordPress#

LangRelay's WordPress plugin translates the rendered page, so /fr/rooms/ is served from the original rooms post and your posts are not duplicated. That changes where some of the head lines come from, and the plugin handles each of them:

  • Hreflang. The plugin prints the set LangRelay sends at wp_head, after your title and meta description, without adding or removing entries. The set lists the original, every language in which that page's translation is live, and x-default on the original. The same lines appear on every version.
  • Canonical. On a translated page the plugin points the existing canonical tag, whether Yoast SEO, Rank Math or WordPress core printed it, at the translated URL, and does the same for og:url. If the page had no canonical, it adds one.
  • lang. On a translated page the plugin sets lang on the <html> element to the language's tag. The original keeps the value WordPress prints for the site language.
  • Title and meta. The title, meta description and Open Graph and Twitter tags your SEO plugin prints are translated with the rest of the page, and you can edit them in the Visual editor's SEO panel.
  • Sitemaps. The plugin leaves them alone. Your SEO plugin's sitemap keeps listing your original URLs, and the translated URLs are linked from the hreflang set, the language switcher and the internal links on translated pages.

After a release, LangRelay fetches each translated URL and checks its lang, its canonical, its own hreflang entry, x-default and noindex. A page that contradicts what was published is flagged on the release instead of being reported as delivered. Your Yoast SEO or Rank Math settings stay as they are. Keep a second translation plugin off the pages LangRelay translates, or each page will print two sets.

Our hreflang guide is the hub for this topic, the multilingual SEO page sums up what the plugin covers, and the guide to translating a WordPress site walks through the setup. To see the plugin's output on your own site, book a demo.

Sources

The pages this one cites, with the day each was read.

  1. 01How to Translate Your Site for Multilingual SEO (WPML documentation, last updated 2026-07-02)wpml.org, checked 6 October 2026
  2. 02WPML SEO: Multilingual Yoast SEO and Rank Math (WPML documentation)wpml.org, checked 6 October 2026
  3. 03Multilingual SEO with Rank Math SEO and WPML (Rank Math knowledge base)rankmath.com, checked 6 October 2026
  4. 04How to change the canonical URL in Yoast SEO for WordPress (Yoast help center)yoast.com, checked 6 October 2026
  5. 05Features (Polylang)polylang.pro, checked 6 October 2026
  6. 06Hreflang tag attributes and Polylang: everything you need to know (Polylang, 2023-02-21)polylang.pro, checked 6 October 2026
  7. 07Filter reference (Polylang documentation)polylang.pro, checked 6 October 2026
  8. 08Multilingual SEO (TranslatePress, last updated 2026-03-03)translatepress.com, checked 6 October 2026
  9. 09SEO Pack (TranslatePress documentation)translatepress.com, checked 6 October 2026
  10. 10Advanced Settings (TranslatePress documentation)translatepress.com, checked 6 October 2026
  11. 11Change hreflang localization (TranslatePress documentation)translatepress.com, checked 6 October 2026
  12. 12WordPress: how does Weglot manage the SEO? (Weglot Help Center, last updated 2026-06-29)support.weglot.com, checked 6 October 2026
  13. 13get_language_attributes() (WordPress Developer Resources)developer.wordpress.org, checked 6 October 2026
  14. 14Localized versions of your pages (Google Search Central, last updated 2026-09-21)developers.google.com, checked 6 October 2026
  • hreflang
  • multilingual SEO
  • WordPress
  • yoast SEO
Part of a guide

Book a demo

See LangRelay on your own site

Book 30 minutes with the team. We translate one of your pages live and walk through review, publishing and multilingual SEO.