How to Add Hreflang Tags in WordPress with Plugin?
WPML, Polylang, TranslatePress and Weglot add hreflang tags for you. Here is what each outputs, how x-default works, and how to check return links.

The easiest way to add hreflang tags in WordPress is to let your multilingual plugin do it. WPML, Polylang, TranslatePress, Weglot and the paid URL plans of GTranslate all print the tags for you once a page has translations, with no code. If your language versions live on separate WordPress sites rather than in one install, a dedicated plugin such as Hreflang Manager lets you connect them by hand.
What the plugin cannot do for you is check that the result follows Google’s rules: every version lists itself and all the others, every link is returned, the codes are valid, and the canonical points at the page itself. That is where most hreflang problems come from, so most of this guide is about checking.
Our team verified the rules against Google Search Central’s hreflang documentation (last updated 21 September 2026) and each plugin’s own docs and WordPress.org listing on 18 November 2026. This page had no recorded Search Console queries when we refreshed it, so the headings follow the questions site owners ask when they set up a second language.
What are hreflang tags and do I need them?
An hreflang tag tells Google that a page has versions in other languages or for other regions, and which URL belongs to which audience. A Spanish speaker searching in Spanish should land on /es/, not on the English page. Google calls these “localized versions” of a page.
You need them when the same page exists in more than one language, or in one language for several regions (for example English for the US, the UK and Australia with different prices or spelling). You do not need them for a single-language site, and they are not a ranking boost on their own.
Two facts from Google’s documentation clear up common confusion:
- “Google doesn’t use
hreflangor the HTMLlangattribute to detect the language of a page.” It works out the language from the content. Hreflang only says which version is meant for whom. - Translated pages are not duplicate content. Google says localized versions “are only considered duplicates if the main content of the page remains untranslated”.
What rules does Google set for hreflang?
Google accepts three equivalent methods and lists a short set of rules that apply to all of them. Pick one method per site; a plugin picks for you.
The rules that break most setups
- Each version lists itself and every other version. A page in three languages carries three hreflang entries, including one pointing at its own URL.
- Links must be returned. If the English page names the Spanish page, the Spanish page must name the English page. Google says that if two pages do not both point to each other, the tags are ignored.
- URLs are fully qualified.
https://example.com/es/, never/es/or//example.com/es/. - Codes are language first, then optional region. Language in ISO 639-1 (
de), region in ISO 3166-1 Alpha 2 (de-AT). A region on its own is invalid, andbemeans Belarusian, not Belgium. - Use real region codes. Google ignores reserved codes such as EU, UN or UK. The United Kingdom is
en-GB. - Scripts are allowed.
zh-Hansandzh-Hant(ISO 15924) separate Simplified and Traditional Chinese, and you can add a region:zh-Hans-US.
The three methods
In the page head, as link elements (what WordPress plugins usually do):
<!-- Checked on 18 Nov 2026 against Google Search Central -->
<link rel="alternate" hreflang="en" href="https://example.com/about/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/sobre-nosotros/" />
<link rel="alternate" hreflang="de-AT" href="https://example.com/at/ueber-uns/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/about/" />As an HTTP Link header, which is the only option for files without an HTML head, such as PDFs:
Link: <https://example.com/guide.pdf>; rel="alternate"; hreflang="en",
<https://example.com/es/guia.pdf>; rel="alternate"; hreflang="es"In an XML sitemap, where each <url> entry lists every version including itself, under the xhtml namespace:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/about/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/about/" />
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/sobre-nosotros/" />
</url>
<url>
<loc>https://example.com/es/sobre-nosotros/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/about/" />
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/sobre-nosotros/" />
</url>
</urlset>Using two methods at once is allowed but pointless, and if they disagree you have created your own conflict. Sitemap hreflang is easier to keep small on huge sites; head tags are easier to inspect.
What does a correct hreflang set look like?
Take one “About” page in English, Spanish and Austrian German, with English as the fallback. Every one of the three URLs carries the same four lines. Only the page you are on changes; the set does not.
Page you are on | Tags it must carry | Common slip |
|---|---|---|
https://example.com/about/ | en, es, de-AT and x-default, all four URLs | Leaving out its own en line |
https://example.com/es/sobre-nosotros/ | The same four lines | Pointing en at the home page instead of /about/ |
https://example.com/at/ueber-uns/ | The same four lines | Using at (not a language code) instead of de-AT |
That symmetry is the whole trick. If you ever have to fix hreflang by hand, write the set once and paste the identical block into every version. When a plugin generates it, the curl check later in this guide should show the same block on each page.
Two practical details. Order does not matter, so do not chase a plugin that sorts languages differently from your menu. And a page that has no translation should either carry no hreflang at all or list only the versions that genuinely exist; pointing at the translated home page as a stand-in breaks the pair, because that home page does not link back to this page.
Which URL structure works best with hreflang?
Hreflang works with all three common structures, and Google says alternate URLs do not need to be on the same domain. The choice affects maintenance more than SEO:
Structure | Example | Good for | Watch out for |
|---|---|---|---|
Language directory | example.com/es/ | One WordPress install, one hosting plan, shared authority | Robots.txt or cache rules that accidentally exclude a directory |
Sub-domain | es.example.com | Separate teams or servers per language | DNS, SSL and caching set up per sub-domain |
Separate domain | example.es | Strong country focus, local trust | Return links must be kept in sync across separate installs |
For most WordPress sites we suggest the language directory. All of the plugins above support it, and keeping everything in one install means one plugin sees every translation and can keep the return links correct by itself.
What does x-default do and should I add it?
x-default names the page for everyone whose language or region you did not list. Google designed it for a language selector page, and it works for a sensible default version too, usually your main language. Google’s May 2023 post on x-default gives the classic case: English and Spanish versions exist, x-default points to English, so a French speaker gets English rather than a random guess.
It is optional, but we recommend it on every multilingual site because it costs one line and removes ambiguity. It needs no language code. On a WordPress site with the language in the URL (/es/, /de/), point x-default at the default-language version or at a real language chooser page if you have one.
Plugins differ here, which is why audit tools so often flag “x-default missing”. See the table below.
Which WordPress plugins add hreflang tags automatically?
We checked each plugin’s documentation and its WordPress.org listing on 18 November 2026. Install counts and update dates come from the WordPress.org plugin API.
Plugin | Hreflang output | x-default | WordPress.org data |
|---|---|---|---|
WPML | Automatic in the head; with the WPML SEO add-on and a Yoast or Rank Math sitemap, moved into the sitemap | Added for the default language in the sitemap (WPML SEO) | Commercial, sold on wpml.org |
Polylang | Automatic for every translated page | Only on the auto-redirected home page; filter to add more | 900,000+ installs, v3.9.2, updated 9 Nov 2026 |
TranslatePress | Automatic, both directions | Optional setting, off by default | 400,000+ installs, v3.4, updated 17 Nov 2026 |
Weglot | Automatic (readme: “automatic hreflang tags”) | Not documented in the readme | 50,000+ installs, v6.4.3, updated 15 Oct 2026 |
GTranslate | Option to add hreflang for translated pages | Not documented | 900,000+ installs, v5.0.2, updated 23 Oct 2026 |
Hreflang Manager | Manual: you connect URLs across sites or a network | You choose the default | 8,000+ installs, v1.20, updated 27 Oct 2026 |
Yoast, Rank Math, SEOPress | No hreflang of their own | Not applicable | They rely on the multilingual plugin |
WPML
WPML’s hreflang page (updated 7 January 2025) says it “automatically inserts hreflang tags to your pages, and updates them as you make changes”. To target a region rather than only a language, edit the language under WPML, Settings, Languages and change its hreflang value, for example to en-GB.
One behaviour surprises people. The WPML SEO add-on writes hreflang into the Yoast SEO or Rank Math XML sitemap when that sitemap is on, adds an x-default entry for the default language there, and “turns off the hreflang tags in the page <head>“ on its first run so search engines do not get the same data twice. If you view source and the tags are gone, check the sitemap before you assume something broke.
Polylang
Polylang adds the tags on its own, using the language code (en, fr) unless you set a regional locale, in which case it outputs codes such as en-GB, converting WordPress underscores to dashes. Its hreflang article (February 2023) says x-default is generated only for the auto-redirected home page, and that page-wide x-default is not built in. The same article gives the filter to add it:
<?php
// Checked on 18 Nov 2026. Polylang: add x-default (pointing at English) to every page.
add_filter( 'pll_rel_hreflang_attributes', function ( $hreflangs ) {
if ( isset( $hreflangs['en'] ) ) {
$hreflangs['x-default'] = $hreflangs['en'];
}
return $hreflangs;
} );Put it in a small must-use plugin rather than a theme’s functions.php, so it survives a theme change. Change 'en' to your default language code. The isset() check keeps it quiet on pages with no English version.
TranslatePress
TranslatePress’s hreflang guide (updated 31 March 2025) says it adds hreflang automatically for each language and “automatically implements bidirectional hreflang tags”. The x-default tag is a setting: Settings, TranslatePress, Advanced tab, Miscellaneous, “Enable the hreflang x-default tag for language”.
Weglot and GTranslate
Both translate through their own service rather than storing translations as WordPress posts. The Weglot readme lists automatic hreflang tags alongside language-specific URLs. The GTranslate listing lists “Add hreflang tags for translated alternatives”, and its changelog ties hreflang to the paid sub-domain and sub-directory options. That matches how it works: the free widget translates in the visitor’s browser on the same URL, so there is no separate page for hreflang to point at.
Hreflang Manager for separate sites
If your English site is example.com and your German site is a different WordPress install on example.de, no translation plugin knows both sides. Hreflang Manager fills that gap: you connect matching URLs from the editor or a central menu, it supports ISO 639-1 languages, ISO 15924 scripts and ISO 3166-1 regions, and the free version allows up to 10 alternates per connection. Remember the return-link rule: the same connection must exist on both sites.
A note on the plugin our older version of this page recommended, HREFLANG Tags Lite: its WordPress.org listing is now closed, so we no longer suggest it.
What about SEO plugins?
Yoast SEO, Rank Math and SEOPress are not translation plugins and do not decide which pages are translations of each other. SEOPress’s own hreflang article says hreflang handling “is an integral part of multilingual plugins” such as Weglot, WPML and Polylang. The SEO plugin’s job is to keep each page’s canonical pointing at itself, so it agrees with the hreflang set.
Still choosing a plugin? Our roundup of WordPress translation plugins compares them on translation workflow, which matters more day to day than hreflang output.
How do I add hreflang tags with a plugin, step by step?
The flow is the same for WPML, Polylang and TranslatePress. We use Polylang for the menu names because it is free on WordPress.org.
- Pick a URL structure first. A language directory (
/es/) is the simplest on one install. Sub-domains and separate domains also work. Changing it later means redirects, so decide before you translate. Our post on permalinks and SEO covers why stable URLs matter. - Install the plugin and add languages. In Polylang, go to Languages and add each language, choosing a regional locale only if you really target regions.
- Translate at least one page. Hreflang only appears on pages that have a translation linked to them. An untranslated page has nothing to point at.
- Set your x-default. Use the plugin setting (TranslatePress), the WPML SEO behaviour, or the Polylang filter above.
- Clear page caches. Cached HTML from before the translation will not have the tags. Our guide to WordPress caching layers shows which layers to purge.
- Check the output with the commands in the next section, on the live site, logged out.
How do I check my hreflang tags are correct?
Search Console no longer helps here. Google deprecated the International Targeting report, which used to list hreflang errors, in 2022, while saying it would keep supporting hreflang (Search Console Help). So checking is up to you or a crawler.
Start with one page. This prints its hreflang set the way a crawler sees it:
# Checked on 18 Nov 2026
curl -sL https://example.com/about/ | grep -io '<link[^>]*hreflang[^>]*>'Then check the return links. This small script reads the set from one page, fetches every alternate, and reports any that do not point back. We tested it on 18 November 2026 against two large multilingual sites.
#!/usr/bin/env bash
# Usage: ./check-hreflang.sh https://example.com/page/
# Lists the hreflang set on a page, then checks every alternate links back.
page="$1"
ua="Mozilla/5.0 (hreflang check)"
tags() { curl -sL -A "$ua" "$1" | grep -io '<link[^>]*hreflang[^>]*>'; }
hrefs() { tags "$1" | grep -o 'href="[^"]*"' | cut -d'"' -f2; }
echo "Hreflang set on $page:"
tags "$page"
echo
for alt in $(hrefs "$page" | sort -u); do
if hrefs "$alt" | grep -qxF "$page"; then
echo "OK $alt links back"
else
echo "MISSING $alt does not link back to $page"
fi
doneIt expects double-quoted attributes, which is what the plugins above print. If your tags live in the sitemap (WPML SEO), open the sitemap file instead and check that every <url> entry lists the full set.
For a whole site, use a crawler that reports hreflang, or one of the two free tools Google itself links to, Aleyda Solis’s hreflang generator and the hreflang testing tool on technicalseo.com. Google notes it does not maintain or check either of them.
While you are checking, confirm robots.txt does not block a language directory. A blocked /es/ cannot return its links. Our guide to editing robots.txt in WordPress shows how to see the file WordPress actually serves.
Common mistakes people report
These come from WordPress.org support threads and Google’s own troubleshooting list. We read each on 18 November 2026; dates are when each thread was opened.
- Missing return tags and self-references across thousands of pages. A Polylang site owner’s audit tools reported missing reciprocal hreflang, missing self-reference, “hreflang to non-canonical” and missing x-default on most of the site, with conflicts ruled out. Thread, March 2021. When a crawler reports this, check whether the flagged pages are untranslated or redirect, since a page that redirects cannot return a link.
- No x-default in the source. An English, French and Romanian Polylang site printed three hreflang tags but no x-default, and other owners joined with the same audit warning. Thread, December 2020. That is documented Polylang behaviour; the filter above is the fix.
- Translated slug leaking into the original’s canonical. A TranslatePress user found the translated slug in the canonical URL of the original-language page; re-saving the post fixed it. Thread, March 2021. A canonical that points at another language contradicts the hreflang set.
- Canonical pointing at a broken translated URL. A reviewer reported their SEO plugin adding canonicals on original pages that led to translated pages without the language folder, and a traffic drop until they removed the translation plugin. Review, November 2021. Spot-check canonicals after any translation plugin update.
- Region-only or reserved codes. Google lists
beused for Belgium (it is Belarusian) and reserved codes such as UK as common mistakes that make Google ignore the annotation. Google troubleshooting list. - Tags vanish from the head after adding WPML SEO. This is by design: with a Yoast or Rank Math sitemap active, WPML SEO moves hreflang into the sitemap. WPML SEO documentation.
Hreflang and canonical tags: how should they work together?
Each language version should have a canonical that points at itself. The Spanish page is canonical for Spanish, the English page for English, and hreflang ties them together. If the Spanish page’s canonical points at the English page, you are telling Google the Spanish page is a duplicate to drop, while hreflang says it is a valid alternate. Crawlers flag this as “hreflang to non-canonical”.
Three related rules keep the set clean:
- Only list URLs that return 200. Redirecting or 404 alternates cannot link back.
- Do not list noindexed pages. A version you hide from search should not be named as an alternate.
- Keep one language per URL. Switching language by cookie or browser setting on the same URL leaves Google one page to index, and hreflang cannot help.
Can I add hreflang tags without a plugin?
Yes, for a small number of fixed pages, by printing link tags from a wp_head callback or adding them to a static sitemap. We do not recommend it beyond a handful of URLs: every new page needs a matching entry on every other version, and one missed update breaks the return links. If your versions are separate WordPress sites, Hreflang Manager gives you the manual control with a UI and cleanup when posts are deleted.
Frequently asked questions
Does hreflang improve rankings?
Not directly. It helps Google show the right version to the right searcher, which improves clicks and reduces visitors bouncing off a page in the wrong language.
Do I need hreflang for one language in several countries?
It is optional, but Google says it is usually best to mark regional variants explicitly, for example en-US, en-GB and en-AU, plus a generic en for everyone else.
Is it hreflang=”en-UK” or “en-GB”?
en-GB. UK is a reserved code, and Google ignores it in hreflang.
Should x-default point to my main language?
Either your main language or a language selector page. Google designed x-default for selector pages but accepts any page.
Why does an audit tool say tags are missing when I can see them?
Usually caching, a logged-in view that differs from the public one, or WPML SEO having moved the tags into the sitemap. Run the curl command logged out on the live URL.
Running a multilingual site also means each language version needs its own social card. Our guide on which image WordPress shows in link previews covers the other set of head tags plugins write for you.
Plugins we build and run
We maintain these ourselves, which is why we can support them on your site.
- BuddyNextThe self-hosted community engine for WordPress
- BuddyXFree community theme, Pro when you outgrow it
- ReignPremium community theme. Add pieces, build anything
- JetonomyCommunity forum and Q&A for WordPress
- EventonomyEvents and RSVPs for WordPress communities
- LearnomyCourses and learning communities on WordPress
- ListoraDirectories and listings your members can browse
- SnipShareCode sharing built for developer communities
- WB Ad ManagerAd placements that turn traffic into revenue
- WP Career BoardA job board your community actually uses
- WP Sell ServicesSell services with offers, orders, and payouts
- MediaVersePhotos, video, and media albums for members
- WB GamificationPoints, badges, and rewards that keep members active
- Product RoadmapPublic roadmaps with voting your users trust
- KanbanomyProject management with a client portal, on your own WordPress site


