SEO with Polylang: setup, URLs and common errors on a multilingual blog

A guide to multilingual SEO with Polylang for a WordPress blog: directory, subdomain or domain, default language, translated slugs and categories, hreflang and x-default, sitemap, menu, redirects and common errors. Based on the Polylang and Google documentation.
Written with AI, reviewed by humans

In this article

See how your brand shows up in AI answers

Book a demo and find out what to fix first, with a GEO specialist.

Book a demo

Reading time: 12 minutes

SEO with Polylang depends on four choices: the URL structure for each language, the slugs, hreflang with the sitemap, and redirects. According to the plugin’s maker, Polylang generates hreflang on its own, but the rest needs checking. Below are the steps for a WordPress blog, the common errors and an audit script.

In short

  • On a single-domain blog, the directory (/en/) is Polylang’s default and takes little upkeep. Subdomains and domains per language require all of them to point to the same WordPress folder.
  • According to the maker, Polylang writes hreflang on translations linked to each other. It adds x-default only on the home page, and the sitemap with Polylang changes with the URL structure.
  • Changing the language code or using the code on the home page causes 404s on the old URLs, and deleting a language removes the posts from the site. So plan 301 redirects.
  • The script below lists the sitemap URLs by language and flags slugs with a suspicious suffix.

What does Polylang do for SEO on its own, and what is left for you?

Polylang links the translations, separates the URLs by language and prints hreflang. According to the maker’s blog, the plugin uses hreflang attributes automatically on a multilingual site. Also, the plugin page on WordPress.org lists compatibility with Yoast SEO.

Four tasks remain for SEO with Polylang. First, the translation must be complete. According to Google, translating only the boilerplate text and leaving the content in one language can create a bad user experience. The same content appears several times in the results. Second, you need to decide the URLs, slugs and sitemap. Next come the redirects. Finally, you need to test.

Google’s rules for hreflang and canonicals are in the WordPress hreflang guide. The general checklist is in the technical SEO audit. Here, the focus is what changes with Polylang.

SEO with Polylang: illustration of a website page split into two language versions linked by a plugin piece, with URL bars and a sitemap

Directory, subdomain or domain: which structure should you use for SEO with Polylang?

On a blog with a single domain, use the directory. According to the Polylang documentation, with pretty permalinks the directory option is already selected, and the advice is to keep it. That way, URLs look like /en/my-post/ and /fr/mon-article/.

However, Google’s page on multilingual sites, cited above, lists the pros and cons of each structure:

  • Directory (example.com/en/): easy to set up and low maintenance, on the same host. On the other hand, it has a single server location, and separating the sites is harder.
  • Subdomain (en.example.com): easy to set up, allows different server locations and separates the sites well. However, users may not recognize the geotargeting from the URL alone.
  • Country domain (example.fr): in Google’s table, it gives a clear country signal, but it costs more, needs more infrastructure and targets a single country.
  • Parameter (?lang=en): Google does not recommend it.

The parameter shows up in Polylang when permalinks are set to plain. So switch to pretty permalinks before you set up SEO.

For subdomains or domains, the documentation warns that all of them must point to the same WordPress root folder, where index.php is. Polylang checks the setup and shows an error if something is wrong. Some hosting providers do not let you choose that folder, so ask yours first. In other words, confirm this before you create the subdomain.

How do the default language URL and the home page URL work in Polylang?

Three options under Languages > Settings > URL modifications change the URLs of a blog that already exists. All of them are in the same Polylang documentation. So decide before you publish the translations, because each one changes addresses that may already be indexed.

  1. Hide the default language code: the documentation says this option keeps the legacy URLs intact when you install Polylang on an existing site. Without it, we infer that default-language URLs would get a prefix, and each one would need a redirect.
  2. Remove /language/ from the URLs: the word appears in archives, such as /language/en/2015/03/. Without it, the URL becomes /en/2015/03/.
  3. Use the language code on the home page: with a static page, the home becomes /en/ and /fr/ instead of /en/home/. According to the home page documentation, the old URL no longer exists and returns a 404.

If the default language code appears in the URL, the site root may redirect. In that case, Polylang puts x-default on the root, as the next section shows.

How do you translate slugs and categories for SEO with Polylang?

Each translation can have its own slug, which you edit in the Yoast field of the translated version. Polylang explains that Yoast lets you translate the title, slug and meta description right in the post. Also, Google accepts localized words in the URL, as its page on multilingual sites says.

WordPress does not accept two posts with the same slug and adds -2 to the second. According to the shared slugs documentation, this is why, in Polylang without Pro, an author’s category ends up as /fr/category/agatha-christie-fr. So if you translate the slug of each version, the suffix does not appear.

Polylang Pro changes two things, according to WordPress.org and the documentation:

  • Sharing the same slug across languages, which requires pretty permalinks and a language that is not set from the content. If Pro is deactivated, only one item among those sharing the slug stays visible.
  • Translating slug bases, such as category, in Languages > Translations, in the “URL slugs” group.

Without Pro, the category base stays the same in both languages. That breaks nothing, but SEO with the free Polylang loses that translation in the URL.

How does Polylang generate hreflang and x-default?

Polylang writes hreflang on both pages when you link the translation in the Languages box of the editor. It uses the WordPress locale and swaps the underscore for a hyphen. For example, en_ZA becomes en-ZA. According to the maker’s blog, Polylang’s hreflang uses the locale when it follows the W3C standard and corrects it when it does not.

No official page we read says whether the free version does the same as Pro, so check the source code of your page. The x-default is the most limited part of hreflang in Polylang. The same blog says the plugin generates it only on the home page, when that page redirects because the default language code appears in the URL. The details of x-default at Google are in the hreflang guide, cited above.

To add x-default to every page, Polylang’s blog gives an example of the pll_rel_hreflang_attributes filter. The version below is adapted from it, with an isset check of our own, and it was not run: test it in a staging environment. Replace en with the value, spelled the same way, that appears in the hreflang attribute of your main language tag (for example en-US).

add_filter( 'pll_rel_hreflang_attributes', function ( $hreflangs ) {
	if ( isset( $hreflangs['en'] ) ) {
		$hreflangs['x-default'] = $hreflangs['en'];
	}
	return $hreflangs;
} );

If Search Console reports an hreflang error right after a translation, wait. According to the Polylang FAQ, Google crawls the original page without hreflang and then the translation with it. The error goes away when Google crawls the original again.

How do the sitemap, the menu and the language switcher work?

The sitemap of a site with Polylang and Yoast depends on the URL structure. According to a December 2022 post on Polylang’s blog, a single domain produces one sitemap for all languages, at sitemap_index.xml. Language by subdomain or domain produces one sitemap per language.

We did not test this with the current version of Yoast, and we found no official page on the WordPress wp-sitemap.xml with Polylang. So open your site’s sitemap and check that each translation appears with the URL of its own language, as the script below does.

To submit the sitemap with Polylang and notify search engines of every change, see the guide on sitemap and IndexNow. For Google, the path is in the guide on how to index a website on Google.

For menus, the documentation says to create one menu per language and assign each one to the theme location. The language switcher only shows a language with at least one published post or page, according to the FAQ. Yoast strings, such as the default title, the meta description and the breadcrumbs, live in Languages > Translations, under the wordpress-seo filter.

How do you redirect by language without hurting SEO?

Google asks you not to redirect users automatically based on the language you assume they speak. That is because the practice can keep people and search engines from seeing all the versions. Googlebot, by the way, usually comes from the US and does not send the Accept-Language header.

Even so, Polylang has an option like that. Browser language detection redirects a visitor who reaches the home page for the first time. After that, a cookie remembers the language of the last visit. To avoid any redirect, the documentation says to turn it off and hide the default language code in the URLs. Offer the language switcher instead.

Redirects for old URLs are a different matter. According to Google, a permanent redirect shows the new target in search results, and the 301 and 308 codes serve that purpose. So use them when you change the language code, the home page or the slug of a translation.

Which common errors hurt SEO with Polylang?

The errors below come from the plugin’s documentation and FAQ, and each one has a simple fix. Review the list before you publish translations and after every settings change, because several items change URLs that already exist.

  1. Content without a language: posts, pages, categories and tags without a language do not appear on the site. So when you install the plugin on an existing blog, assign the default language to everything.
  2. Changing the language code: according to the documentation, this changes the URL of every post and page in that language and causes 404 errors without a redirect.
  3. Deleting a language: the posts stay in the admin, but they lose their language, disappear from the site and lose the link to their translations.
  4. A theme that loads content with Ajax: the FAQ says the menu may not switch language along with the page. The fix is to turn off the theme’s Ajax.
  5. A language with no published post: it does not appear in the switcher, and readers cannot reach those versions.
  6. Translating only the boilerplate: Google warns that this can create a bad user experience, as seen above.

How do you audit the sitemap by language on a site with Polylang?

The script below, in Python with no external libraries, checks the sitemap of a site with Polylang. It reads the index, adds up the URLs by language and flags repeated URLs and slugs that end in -2 or in the language code.

Use python audit_sitemap_languages.py SITEMAP_URL es,fr, with the prefixes (comma-separated) of the languages that have a directory. If English is your default language and its code is hidden, leave it out. URLs without a prefix count as “no prefix”, which in Polylang is usually the default language.

import re
import sys
import urllib.request
from collections import Counter
from urllib.parse import urlparse


def urls(sitemap):
    xml = urllib.request.urlopen(sitemap, timeout=20).read().decode("utf-8", "replace")
    locs = re.findall(r"<loc>\s*([^<\s]+)\s*</loc>", xml)
    if "<sitemapindex" in xml:
        return [u for s in locs for u in urls(s)]
    return locs


def audit(sitemap, languages):
    all_urls = urls(sitemap)
    count, suspects = Counter(), []
    for u in all_urls:
        parts = urlparse(u).path.strip("/").split("/")
        slug = parts.pop()
        first = (parts or [slug]).pop(0)
        count[first if first in languages else "(no prefix)"] += 1
        tail = re.search(r"-(\d|" + "|".join(map(re.escape, languages)) + r")$", slug)
        if tail:
            suspects.append(u)
    print(f"{len(all_urls)} URLs, {len(set(all_urls))} unique")
    for lang, n in sorted(count.items()):
        print(f"  {lang}: {n}")
    for u in suspects:
        print(f"  SUSPICIOUS SLUG (suffix -2, -3 or language code): {u}")


sitemap, languages = (sys.argv[1:] + [""])[:2]
audit(sitemap, [i for i in languages.split(",") if i])

We ran the script against a local test sitemap, without Polylang, with seven URLs, one repeated and two slugs with suffixes. It counted the six unique URLs, separated those under the en prefix we passed and flagged the two slugs. However, natural slugs such as top-5 trigger false positives, so check each warning in the sitemap with Polylang. The script does not test hreflang or HTTP status; for that, use the test in the hreflang guide.

Frequently asked questions

Is the free Polylang enough for multilingual SEO?

For URLs by language and for translating Yoast, yes. According to WordPress.org, the free plugin and Pro share the same core, which includes the language in the URL by code, subdomain or domain. Only Pro shares slugs across languages and translates slug bases. Check hreflang in the source code, because the plugin page does not mention it.

Does Polylang translate the Yoast SEO title and meta description?

Yes, in two ways. In the post translation, you edit the title, slug and meta description in the Yoast fields. For Yoast’s global texts, use Languages > Translations and filter by wordpress-seo. According to Polylang, the free plugin is enough to translate the texts of Yoast SEO and Yoast SEO Premium.

What happens to the URLs if I deactivate Polylang?

With the language in the directory, the URLs lose the language information, and external links to them break, according to the documentation. Deleting the plugin does not remove the languages and links from the database. To clean everything up, the FAQ says to define PLL_REMOVE_ALL_DATA in wp-config.php before you delete it.

Want to know how your brand shows up in AI answers today?

Book a demo and see how your brand shows up in AI answers, with support from a GEO specialist.

Main sources

About this articleWritten with AI and reviewed by humans, with verified sources. Found something out of date? Write to the NotHuman team.

Get new NotHuman articles by email

By subscribing, you agree to receive blog articles by email and to the Privacy Policy. Unsubscribe any time.

Keep reading

Demo

Want to know how your brand shows up in AI answers today?

Book a demo and see how your brand shows up in AI answers, with support from a GEO specialist.

Book a demo

Your privacy

We use necessary cookies to make the site work and Google Analytics and Microsoft Clarity statistics cookies to improve our content. You can decline the statistics ones; in the EU, UK and Switzerland they are only turned on after you accept. Cookie Policy.

Cookie preferences

Cookie Policy