Check 30.17 · Multilingual tracking and maintenance

Test cross-language links

Regularly test the links between language versions: hreflang, switcher and content links, with Screaming Frog, a spreadsheet or a free crawl script.

Priority
Important
Difficulty
Intermediate
Estimated time
2 to 4 h, then ongoing
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

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 hreflang annotation 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

  • hreflang taken 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 hreflang target or switcher link returning 3xx, 4xx or 5xx;
  • every annotation has its return link;
  • the language of the target page (<html lang>) matches the hreflang code 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

  1. Configuration > Spider > Crawl: tick Store Hreflang and Crawl Hreflang.
  2. Start the crawl from the homepage, or in list mode with the homepages of each language if the versions are on different domains.
  3. Hreflang tab: go through the filters that report targets not returning 200, missing return links, non-canonical or noindex return links, and incorrect language codes. Export every non-empty filter.
  4. 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.

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_PAGES to 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

Common mistakes

  • Testing only the homepage: the homepage's hreflang tags 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 hreflang and 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

Updated on

Topic checklist (PDF)

And now?

In the “Multilingual tracking and maintenance” topic

  1. Segment traffic by language and country URL
  2. Segment conversions and revenue by market
  3. Track rankings by search engine and country
  4. Track impressions and CTR by version
  5. Track indexing by language
  6. Track backlinks by market
  7. Track AI mentions and citations by language
  8. Track AI traffic and share of voice by market
  9. Compare business performance
  10. Identify underexploited markets and weak translations
  11. Detect missing or outdated translations
  12. Detect changes to the source content
  13. Notify the people responsible for translations
  14. Review AI translations
  15. Automate hreflang and canonical tests
  16. Detect the actual language and untranslated strings
  17. Test cross-language links
  18. Synchronize facts and specifications
  19. Synchronize stock if applicable
  20. Manage market-specific prices
  21. Test all versions after each deployment
  22. Define editorial sign-off for each language
  23. Integrate multilingual tests into CI/CD