In short
A well-designed language switcher can still fail on part of the site: missing from error or search pages, linking to the homepage on blog posts, to a redirecting URL on products, or out of line with the hreflang annotations. The task is to check the switcher on every page, or on a sample of each template in each language, with a crawler or a script, then fix the faulty templates. Once it is done, every indexable page offers, in its HTML, a link to each of its existing versions that returns 200 directly.
Why it matters
Google recommends letting users switch language through links to the page's other language versions, and only reliably follows <a> elements with an href attribute. Designing the switcher is covered in provide a crawlable language switcher (opens in a new tab); this task checks that it works everywhere.
The switcher depends on data specific to each page: the list of its translations. Flaws therefore show up template by template:
- forgotten templates: category, search, author and 404 pages, pages generated by a shop or form plugin;
- silent fallback: when the plugin does not find the translation, the link leads to the language's homepage, see link to the equivalent page rather than the homepage (opens in a new tab);
- outdated URLs: the translated slug has changed, and the switcher points to the old URL, which redirects;
- mismatch with
hreflang: the two are produced by different code and do not point to the same page; - link to an unpublished translation, which returns 404 or carries a
noindex.
An inconsistent switcher sends the visitor to the wrong place and gives crawlers links that contradict the hreflang annotations.
What it improves
- Navigation between languages that is reliable on every template, with no forced homepage.
- Discovery of language versions through links, in addition to
hreflang. - Consistent signals The switcher's links and the
hreflangannotations point to the same pages. - Fewer internal redirects and links to errors.
- Rankings No direct effect.
How to check
With Screaming Frog
Configuration > Custom > Extraction: add an XPath extractor that reads the switcher's links, for example//nav[contains(@class,'lang-switcher')]//a/@href. Adapt the path to your theme's markup. Add a second extractor for thehreflangannotations in the<head>://link[@rel='alternate'][@hreflang]/@href.Configuration > Custom > Search: a “Does Not Contain” filter on the switcher's class (lang-switcher) lists the pages where it is missing.Configuration > Spider > Crawl: tickStore HreflangandCrawl Hreflangto populate theHreflangtab.- Run the crawl, then export the
Custom Extractiontab and compare the two extractions row by row. - Switcher links that redirect or return an error appear in the
Bulk Export > Response Codesexports of inlinks to 3xx and 4xx URLs, with the source page and the anchor.
Without a paid tool
This dependency-free Python script reads a list of URLs (one per line), extracts the switcher's links and the hreflang annotations of each page, then reports the discrepancies:
#!/usr/bin/env python3
"""Usage: python3 selecteur.py urls.txt > selecteur.csv"""
import csv
import sys
import urllib.error
import urllib.request
from html.parser import HTMLParser
from urllib.parse import urljoin
MARKERS = ("lang-switcher", "language-switcher", "choose a language")
HEADERS = {"User-Agent": "audit-selecteur"}
class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(self, *args, **kwargs):
return None
OPENER = urllib.request.build_opener(NoRedirect)
STATUS = {}
def status(url):
if url not in STATUS:
try:
with OPENER.open(urllib.request.Request(url, method="HEAD", headers=HEADERS), timeout=15) as r:
STATUS[url] = r.status
except urllib.error.HTTPError as error:
STATUS[url] = error.code
except urllib.error.URLError:
STATUS[url] = 0
return STATUS[url]
class Page(HTMLParser):
def __init__(self, base):
super().__init__()
self.base, self.alternates, self.switcher = base, {}, {}
self.tag, self.level, self.lang = None, 0, ""
def handle_starttag(self, tag, attrs):
a = {k: (v or "") for k, v in attrs}
if tag == "html":
self.lang = a.get("lang", "").lower()
if tag == "link" and "alternate" in a.get("rel", "") and a.get("hreflang"):
self.alternates[a["hreflang"].lower()] = urljoin(self.base, a.get("href", ""))
label = f"{a.get('class', '')} {a.get('aria-label', '')} {a.get('id', '')}".lower()
if self.tag is None and any(m in label for m in MARKERS):
self.tag, self.level = tag, 0
if tag == self.tag:
self.level += 1
if tag == "a" and (self.tag or a.get("hreflang")):
code = (a.get("hreflang") or a.get("lang") or "?").lower()
self.switcher[code] = (urljoin(self.base, a.get("href", "")), a.get("rel", ""), a.get("href", ""))
def handle_endtag(self, tag):
if tag == self.tag:
self.level -= 1
if self.level == 0:
self.tag = None
writer = csv.writer(sys.stdout)
writer.writerow(["page", "langue", "probleme", "detail"])
for url in (line.strip() for line in open(sys.argv[1], encoding="utf-8") if line.strip()):
try:
with urllib.request.urlopen(urllib.request.Request(url, headers=HEADERS), timeout=20) as r:
page = Page(url)
page.feed(r.read().decode("utf-8", "replace"))
except urllib.error.URLError as error:
writer.writerow([url, "", "page unreachable", error])
continue
if not page.switcher:
writer.writerow([url, "", "switcher missing from the HTML", ""])
continue
for code, target in page.alternates.items():
if code == "x-default":
continue
if code not in page.switcher and code.split("-")[0] == page.lang.split("-")[0]:
continue
if code not in page.switcher:
writer.writerow([url, code, "hreflang language missing from the switcher", target])
elif page.switcher[code][0] != target:
writer.writerow([url, code, "target differs from the hreflang", f"{page.switcher[code][0]} / {target}"])
for code, (target, rel, raw) in page.switcher.items():
if raw.startswith(("#", "javascript:")):
writer.writerow([url, code, "non-crawlable link", raw])
continue
if "nofollow" in rel:
writer.writerow([url, code, "nofollow link", target])
code_http = status(target)
if code_http != 200:
writer.writerow([url, code, f"target returns {code_http}", target])
python3 selecteur.py urls.txt > selecteur.csv
Adapt MARKERS to the class, id or aria-label of your switcher's container. The script also treats as switcher links every <a> that carries an hreflang attribute, and tolerates a switcher that leaves out the page's own language (read from <html lang>). It compares URLs as they are: a trailing slash difference is enough to produce a row, which is intended. If your server rejects HEAD requests (code 405), replace method="HEAD" with method="GET".
Expected result: a file that contains only the header. The script reads the HTML returned by the server, without JavaScript, like a crawler that does not run scripts.
How to implement
Step 1 — Build the sample
On a site of a few hundred pages, test everything. Beyond that, take at least three URLs of each template in each language, plus the exception pages:
| Template | fr | de | en |
|---|---|---|---|
| Homepage | / |
/de/ |
/en/ |
| Category | /thes/the-vert/ |
/de/tee/gruener-tee/ |
/en/tea/green-tea/ |
| Product | /thes/sencha-bio/ |
/de/tee/bio-sencha/ |
/en/tea/organic-sencha/ |
| Blog post | /blog/temperature-infusion/ |
/de/blog/ziehtemperatur/ |
/en/blog/brewing-temperature/ |
| Search | /?s=sencha |
/de/?s=sencha |
/en/?s=sencha |
| Untranslated page | /presse/ |
— | — |
| 404 error | /page-inexistante/ |
/de/nicht-vorhanden/ |
/en/missing/ |
Fictitious example. The “untranslated page” row checks the behavior decided in plan for missing translations (opens in a new tab): language hidden, or a link to the closest page, announced as such.
Step 2 — Run the check and sort the discrepancies
| Reported problem | Usual cause | Fix |
|---|---|---|
| Switcher missing from the HTML | Template without the component, or switcher injected in JavaScript | Add the component to the template; render it server-side |
Target differs from the hreflang |
Two sources of truth, or fallback to the homepage | Generate both from the same translation table |
hreflang language missing from the switcher |
Switcher that wrongly hides languages | Review the display condition |
| Target returns 301 or 302 | Translated slug changed, trailing slash, http |
Generate the canonical URL of the translation |
| Target returns 404 | Translation deleted or unpublished | Hide the language, see update annotations when a translation is removed (opens in a new tab) |
| Non-crawlable link | href="#" filled in by script, <select> |
Go back to <a href> links |
nofollow link |
Theme or plugin setting | Remove the attribute |
Step 3 — Fix by environment
WordPress
Versions WordPress 6.8 and later (checked up to 7.1); WPML 4 and 5, Polylang 3.
With Polylang or WPML, a switcher added through a menu or a widget only appears in the areas the template displays: check the search, archive and 404 templates, and the WooCommerce ones. In a custom theme, build it with pll_the_languages(['raw' => 1]) or the wpml_active_languages filter, which return for each language the URL of the current page's translation, and check the behavior when the translation is missing: Polylang's hide_if_no_translation option hides the language, and WPML offers an equivalent setting in the language switcher options.
Shopify
Versions Online Store 2.0 themes, all Shopify plans, November 2026.
The localization form in Shopify themes uses href="#" links and sends the language through a form: the script reports it as non-crawlable. Add a list of links built with localization.available_languages to the footer, as described in provide a crawlable language switcher (opens in a new tab), and check it on product, collection, blog and search pages.
Drupal
Versions Drupal 10 and 11, Language Switcher Extended module 8.x-1.2.
The “Language switcher” block must be placed in a region of the front-end theme displayed on every page, including error and search pages. The core block offers every language, even when the content has no translation. In that case, the Language Switcher Extended module lets you hide the language, display it without a link or link to the language's homepage; prefer one of the first two options.
Laravel
Versions Laravel 11 to 13.
Place the component in the shared layout, including in the error views (resources/views/errors/), and generate its URLs from the same table as the hreflang annotations. One feature test per template checks that it is there:
public function test_language_switcher_links_to_equivalent_pages(): void
{
$this->get('/de/preise')
->assertOk()
->assertSee('href="https://example.com/fr/tarifs" hreflang="fr"', false)
->assertSee('href="https://example.com/en/pricing" hreflang="en"', false);
}
Next.js
Versions Next.js 15 and 16 (App Router), next-intl 4.
With next-intl, render the switcher in the app/[locale]/layout.tsx layout, server-side, and check that it also appears in not-found.tsx. If your paths are translated, build the links from the routing's pathnames configuration, not by replacing the prefix of the current URL.
Step 4 — Automate
Add the script to acceptance testing or continuous integration, with a list of representative URLs for each template, and make the deployment fail if the result file contains a row. See integrate multilingual tests into CI/CD (opens in a new tab).
Good to know: if the site serves different HTML to mobile devices, run the check again with a smartphone user agent: Google crawls and indexes the mobile version first, and the switcher there is often collapsed into a menu loaded separately.
Common mistakes
- Testing only the homepage, where the switcher almost always works.
- Forgetting error, search and archive pages, generated by other templates.
- Comparing the switcher with the browser rendering rather than with the server's HTML: a script-injected switcher looks correct.
- Accepting redirects in the switcher's links because the final page is the right one.
- Letting the switcher and the
hreflangannotations be computed by two different plugins. - Linking to a language with no translation without warning the visitor.
Frequently asked questions
How do you check the language switcher on every page of a site?
Crawl the site while extracting, on each page, the switcher's links and the hreflang annotations, for example with Screaming Frog's custom extraction or a script that reads the HTML. Then compare the two lists language by language, and check that each target returns 200 without a redirect. On a large site, test at least three pages of each template in each language, including error pages.
Should the switcher's links match the hreflang annotations?
Yes, for the same page and the same language, the switcher's link and the hreflang annotation must point to the same URL. Both describe the same relationship between language versions: if they differ, one of them is wrong, often a fallback to the homepage or an old URL that redirects. The safest approach is to generate both from the same translation table.
What should the switcher show when a page is not translated?
Two choices are consistent: hide the language for that page, or link to the closest page in that language while saying so clearly. Avoid linking to the homepage without warning, or to a URL that returns a 404 error. Whichever you choose, apply it the same way on every template and remove the corresponding hreflang annotation.
Is a switcher link that redirects a problem?
Yes, even if the final page is the right one. Every internal link that redirects adds a request for the visitor and for crawlers, and often signals outdated data, such as a modified translated slug. If the switcher's link redirects, the corresponding hreflang annotation probably also points to a non-canonical URL. Point the switcher directly to the URL that returns 200.
Resources
- Google Search Central: Managing multi-regional and multilingual sitesdevelopers.google.com
- Google Search Central: Make your links crawlabledevelopers.google.com
- Google Search Central: Localized versions of your pagesdevelopers.google.com
- Screaming Frog: Custom extractionscreamingfrog.co.uk
- Polylang: Function referencepolylang.pro
- Shopify: localization Liquid objectshopify.dev
- Drupal: Language Switcher Extendeddrupal.org
Updated on
Topic checklist (PDF)