In short
Cross-language links connect one language version to another: hreflang annotations, language switcher links, and links placed in content, menus or the footer. Testing them means crawling each language, classifying each link by its source and destination language, then checking that the intended links point to the equivalent page with a 200 and that unintended links to another language have disappeared. Once the task is in place, a report per language comes out every month and after every deployment, and it is empty.
Why it matters
Cross-language links degrade without anyone touching the switcher or the hreflang tags. A translated slug is changed, a translation is unpublished, a writer pastes the URL of the French product page into a German article, a footer menu was only created in the main language. Each isolated change breaks a link, and nothing flags it.
The consequences are twofold:
- For search engines: Google ignores an
hreflangannotation when the two pages do not point to each other, and it only reliably follows<a href>links. A target that returns a 404, redirects or is not canonical weakens the whole group of versions. Google also recommends adding links to the other language versions of a page: if they are wrong, those are the links bots follow. - For visitors: a content link that switches the reader into another language takes them off their journey. It also passes internal link equity to the wrong version, which skews the internal linking of each language (opens in a new tab).
The initial setup of hreflang and the switcher is covered elsewhere. This task puts in place the recurring check that detects their regressions.
What it improves
hreflangtaken into account Fewer annotations ignored for lack of reciprocity or a valid target.- Crawling Bots discover each version through links that return 200 directly.
- Internal linking by language Internal link equity stays in the version where it belongs.
- Visitor journey Fewer accidental switches to a language the reader does not speak.
- AI answers A generative engine that follows a page's links is less likely to land on the wrong language. Indirect effect, not documented by the vendors.
- Rankings No direct effect; the effect comes through the versions being correctly taken into account.
How to check
Quick check on one page, from a terminal:
curl -s https://example.com/de/tee/gruener-tee/ | grep -o '<link[^>]*hreflang[^>]*>'
Each listed URL must return 200 and return the same list. Check the response of each target:
for url in $(curl -s https://example.com/de/tee/gruener-tee/ | grep -o 'hreflang="[^"]*" href="[^"]*"' | sed 's/.*href="//;s/"$//'); do
printf '%s ' "$url"; curl -s -o /dev/null -w '%{http_code}\n' "$url"
done
The order of attributes varies from site to site: adjust the expression if your HTML writes href before hreflang.
A compliant result, across the site:
- no
hreflangtarget or switcher link returning 3xx, 4xx or 5xx; - every annotation has its return link;
- the language of the target page (
<html lang>) matches thehreflangcode that points to it; - no content, menu or footer link to another language, except listed exceptions.
How to implement
The examples follow Thé des Lisières, a fictional shop in French (/), German (/de/) and English (/en/).
Step 1 — Write down the expected rules
A test only makes sense if you know what is allowed. Draw up this table once, with the team:
| Link type | Allowed to another language? | Rule to test |
|---|---|---|
hreflang annotation (HTML, HTTP header or sitemap) |
Yes, by definition | Target returns 200, canonical, indexable, reciprocal, language matching the code |
| Language switcher | Yes | Same target as the hreflang for that language, 200 with no redirect |
| Link in the content | No, except for exceptions | Documented exception: untranslated “press” page, resource available in only one language |
| Menu, footer, breadcrumb | No | Always to the same language |
Structured data links (url, @id) |
No | URL in the page's language, see adapt url to the language (opens in a new tab) |
Also note how the language is read from the URL: path prefix (/de/), subdomain (de.example.com) or country-code domain (example.de). The tools below need it.
Step 2 — Check with Screaming Frog
Configuration > Spider > Crawl: tickStore HreflangandCrawl Hreflang.- Start the crawl from the homepage, or in list mode with the homepages of each language if the versions are on different domains.
Hreflangtab: go through the filters that report targets not returning 200, missing return links, non-canonical ornoindexreturn links, and incorrect language codes. Export every non-empty filter.- For content links:
Bulk Export > Links > All Inlinks. The file contains, for each internal link, the source, the destination and the link position (content, navigation, footer).
The free version is limited to 500 URLs: on a larger site, crawl one language at a time in list mode, from that language's sitemap.
Step 3 — Classify the links in a spreadsheet
Paste the links export into Google Sheets, with the source URL in column B and the destination in column C, then add three columns. Formulas for an English-locale spreadsheet, for languages in a path prefix with French at the root:
Source language (column N):
=IFERROR(REGEXEXTRACT(B2,"^https?://[^/]+/(de|en)/"),"fr")
Destination language (column O):
=IFERROR(REGEXEXTRACT(C2,"^https?://[^/]+/(de|en)/"),"fr")
Cross-language link (column P):
=IF(N2<>O2,"Cross-language","")
Filter column P on “Cross-language”, then discard the rows whose position is the switcher. What remains is the list of content and navigation links to fix. A pivot table (rows: source language, columns: destination language, value: number of links) gives the matrix of leaks between languages.
For country-code domains, replace the expression with a domain match: =IFERROR(REGEXEXTRACT(B2,"^https?://(?:www\.)?example\.(de|co\.uk)"),"fr").
Step 4 — Or run a free script
This dependency-free Python script crawls each language from its homepage, reads the hreflang tags, the switcher and every internal link, then writes a CSV of problems and prints the matrix of content links between languages:
#!/usr/bin/env python3
"""Usage: python3 interlangues.py https://example.com/ https://example.com/de/ https://example.com/en/ > interlangues.csv"""
import csv
import sys
import urllib.error
import urllib.request
from collections import Counter, deque
from html.parser import HTMLParser
from urllib.parse import urldefrag, urljoin, urlparse
PREFIXES = {"de": "de", "en": "en"} # first path segment -> language
HOSTS = {} # country-code domains, e.g. {"example.de": "de"}
DEFAULT = "fr" # language of URLs without a prefix
MAX_PAGES = 300 # pages crawled per language
SWITCHER = ("lang-switcher", "language-switcher")
SKIP = (".pdf", ".jpg", ".jpeg", ".png", ".webp", ".avif", ".svg", ".zip", ".mp4")
HEADERS = {"User-Agent": "audit-interlangues"}
def language_of(url):
parts = urlparse(url)
if parts.hostname in HOSTS:
return HOSTS[parts.hostname]
return PREFIXES.get(parts.path.strip("/").split("/")[0], DEFAULT)
class Page(HTMLParser):
def __init__(self, base):
super().__init__()
self.base, self.lang, self.canonical = base, "", ""
self.alternates, self.links = {}, []
self.tag, self.level = 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 "canonical" in a.get("rel", ""):
self.canonical = urljoin(self.base, a.get("href", ""))
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('id', '')} {a.get('aria-label', '')}".lower()
if self.tag is None and any(m in label for m in SWITCHER):
self.tag, self.level = tag, 0
if tag == self.tag:
self.level += 1
href = a.get("href", "")
if tag == "a" and href and not href.startswith(("#", "mailto:", "tel:", "javascript:")):
target = urldefrag(urljoin(self.base, href))[0]
self.links.append((target, self.tag is not None or bool(a.get("hreflang"))))
def handle_endtag(self, tag):
if tag == self.tag:
self.level -= 1
if self.level == 0:
self.tag = None
class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(self, *args, **kwargs):
return None
OPENER = urllib.request.build_opener(NoRedirect)
CACHE = {}
def fetch(url):
if url not in CACHE:
try:
with OPENER.open(urllib.request.Request(url, headers=HEADERS), timeout=20) as r:
page = Page(url)
if "html" in r.headers.get("Content-Type", ""):
page.feed(r.read().decode("utf-8", "replace"))
CACHE[url] = (r.status, page)
except urllib.error.HTTPError as error:
CACHE[url] = (error.code, None)
except urllib.error.URLError:
CACHE[url] = (0, None)
return CACHE[url]
seeds = sys.argv[1:]
hosts = {urlparse(s).hostname for s in seeds} | set(HOSTS)
queue, seen, crawled, matrix = deque(seeds), set(seeds), Counter(), Counter()
writer = csv.writer(sys.stdout)
writer.writerow(["page", "language", "type", "problem", "target"])
while queue:
url = queue.popleft()
lang = language_of(url)
if crawled[lang] >= MAX_PAGES:
continue
status, page = fetch(url)
if status != 200 or page is None:
continue
crawled[lang] += 1
if page.lang and page.lang.split("-")[0] != lang:
writer.writerow([url, lang, "page", f"html lang = {page.lang}", ""])
for code, target in page.alternates.items():
if code == "x-default":
continue
code_http, other = fetch(target)
if code_http != 200 or other is None:
writer.writerow([url, lang, "hreflang", f"target returns {code_http}", target])
continue
if language_of(target) != code.split("-")[0]:
writer.writerow([url, lang, "hreflang", f"code {code} to a {language_of(target)} URL", target])
if other.canonical and other.canonical != target:
writer.writerow([url, lang, "hreflang", "non-canonical target", target])
if target != url and url not in other.alternates.values():
writer.writerow([url, lang, "hreflang", "no return link", target])
for target, in_switcher in page.links:
if urlparse(target).hostname not in hosts or target.lower().endswith(SKIP):
continue
if target not in seen:
seen.add(target)
queue.append(target)
target_lang = language_of(target)
if target_lang == lang:
continue
if in_switcher:
if fetch(target)[0] != 200:
writer.writerow([url, lang, "switcher", f"target returns {fetch(target)[0]}", target])
elif page.alternates and target not in page.alternates.values():
writer.writerow([url, lang, "switcher", "target missing from hreflang", target])
continue
matrix[(lang, target_lang)] += 1
writer.writerow([url, lang, "content", f"link to language {target_lang}", target])
print("Pages crawled:", dict(crawled), file=sys.stderr)
for (source, target), count in sorted(matrix.items()):
print(f"Content links {source} -> {target}: {count}", file=sys.stderr)
python3 interlangues.py https://example.com/ https://example.com/de/ https://example.com/en/ > interlangues.csv
Set PREFIXES, HOSTS and DEFAULT to match your URL structure, and SWITCHER to match the class or id of your switcher's container. The script reads the HTML returned by the server, without executing JavaScript, and only reads the hreflang tags in the <head>: if you declare them in the sitemap, check it separately. It compares URLs as they are: a trailing slash difference produces a line, which is intentional. Compliant result: a CSV that contains only the header.
Tip: for a first pass on a large site, lower
MAX_PAGESto 50: template defects show up in the first pages of each type, and the report stays readable.
Step 5 — Fix at the source
| Problem reported | Usual cause | Fix |
|---|---|---|
hreflang target returns 404 or 410 |
Translation deleted or unpublished | Update the annotations (opens in a new tab) |
| Target returns 301 or 302 | Translated slug changed, trailing slash | Generate the canonical URL of the translation, see exclude redirects and nonexistent pages (opens in a new tab) |
| No return link | Translation linked on one side only in the CMS | Link the two pieces of content, see check reciprocity (opens in a new tab) |
| Non-canonical target | The translation's canonical points to another URL |
Align hreflang and canonical (opens in a new tab) |
| Code different from the URL's language | Translations wrongly associated (German linked as English) | Fix the association in the multilingual plugin |
| Content link to another language | URL copied from another version, untranslated menu | Fix links to the default language (opens in a new tab) |
Fix the template or the data that produces the link, not the pages one by one: a footer defect is repeated across thousands of URLs.
Step 6 — Schedule the check
- After every deployment: the script, on a sample of URLs per template and per language, as part of testing all versions after each deployment (opens in a new tab).
- Every month: the full crawl of each language, with the dated CSV archived to follow the trend.
- In continuous integration: the build fails if the CSV contains a line, see integrate multilingual tests into CI/CD (opens in a new tab).
- A named owner per language for content links, which are more a matter for the editorial team than for development.
Common mistakes
- Testing only the homepage: the homepage's
hreflangtags are almost always right; the defects are on product pages, articles and archives. - Accepting a target that redirects because the final page is the right one.
- Looking only at
hreflangand ignoring content links, which are the most numerous to leak to another language. - Judging from the browser: a switcher or links rewritten by JavaScript look correct while the HTML served to bots is not.
- Letting a translation tool rewrite links at display time without checking the final HTML of each language.
- Fixing page by page a defect that comes from a template or a menu.
Frequently asked questions
What is a cross-language link on a multilingual website?
A cross-language link connects one language version of a site to another: an hreflang annotation, a language switcher link, or a link placed in content, a menu or a footer. The first two are intentional and must point to the equivalent page, returning 200 and canonical. Content links to another language are most often errors, such as a URL copied from the French version.
How do you find links that send users to the wrong language?
Crawl the site, export all internal links with their source and destination, then infer the language of each URL from its prefix or domain. The rows where the source language differs from the destination language, the language switcher aside, are the links to fix. A spreadsheet with two extraction formulas and a pivot table is enough, without any paid tool.
Is an hreflang without a return link really ignored by Google?
Yes. Google's documentation states that if two pages do not point to each other, the hreflang annotations are ignored. Each language version must list all the other versions and itself. A missing return link often comes from a translation linked on one side only in the CMS or from a target that redirects to a URL other than the one declared.
How often should you test the links between language versions?
Test a sample of pages from each template and each language after every deployment, and run a full crawl of each language every month. Cross-language links break mostly when slugs change, translations are unpublished and templates change. Archive each dated report to spot regressions, and assign content fixes to an owner for each language.
Resources
- Google Search Central: localized versions of your pagesdevelopers.google.com
- Google Search Central: managing multi-regional and multilingual sitesdevelopers.google.com
- Google Search Central: making links crawlabledevelopers.google.com
- Screaming Frog SEO Spider: user guidescreamingfrog.co.uk
- Google Sheets Help: REGEXEXTRACTsupport.google.com
- Python: html.parser moduledocs.python.org
Updated on
Topic checklist (PDF)