Check 22.11 · International architecture

Link to the equivalent page rather than the homepage

Point the language switcher and hreflang to the same page in the other language, not to the homepage: method, checking script and code for each CMS.

Priority
Critical
Difficulty
Intermediate
Estimated time
2 h to 2 days
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

When a visitor reading the “Chaussure de randonnée” (hiking boot) product page in French clicks “Deutsch”, they must land on the same product page in German, not on the German homepage. hreflang annotations follow the same rule: each one connects a page to its exact equivalents. Once this task is done, every language link and every hreflang on a deep page points to a deep page, and the target links back to the starting page.

Why it matters

A switcher that leads back to the homepage makes the visitor lose what they were reading. They have to navigate again, often through the internal search or the menu, or they give up. It is one of the most common flaws of multilingual themes: the link is hard-coded to /de/, or the plugin does not know the translation of the current page.

For search engines, hreflang annotations describe equivalent pages. Google requires each version to list all the others and itself, and the links to be reciprocal: if two pages do not point to each other, the annotations are ignored. A product page that names the German homepage as its equivalent produces exactly this situation: the German homepage obviously does not link back to the product page. As a result, Google does not know which version to show to a German-speaking user searching for that product.

Internal linking suffers too. A switcher present on every page and pointing to the homepages sends thousands of links to three URLs, and none to the deep translated pages, which can then only be reached through the navigation of their own language.

Finally, AI agents browsing on behalf of a user follow the same links: a language change that loses the page interrupts their task.

What it improves

  • Visitor experience Changing language keeps the page, the product, the article.
  • hreflang Reciprocal pairs, which Google therefore takes into account.
  • The right version shown in the results for each language, a direct consequence of valid annotations.
  • Internal linking Each translated page receives links from its equivalents.
  • Conversion Fewer drop-offs when changing language. A plausible effect, to be measured on your site.
  • Rankings No direct effect.

How to check

Open a deep page, a product page for example, then click each language in the switcher. You must land on the same product page. Repeat the test on an article, a category and a service page.

For a large-scale check, this Python script, with no dependencies, reads the hreflang annotations and the language links of each page, flags those pointing to a homepage and checks that the target links back to the starting page:

# check_language_links.py
import sys
import urllib.error
import urllib.request
from html.parser import HTMLParser
from urllib.parse import urljoin, urlparse

HOMES = {'/', '/fr/', '/de/', '/en/'}
cache = {}


class LanguageLinks(HTMLParser):
    def __init__(self, base):
        super().__init__()
        self.base = base
        self.links = {}

    def handle_starttag(self, tag, attrs):
        attrs = dict(attrs)
        if tag in ('a', 'link') and attrs.get('hreflang') and attrs.get('href'):
            self.links[(tag, attrs['hreflang'])] = urljoin(self.base, attrs['href'])


def fetch(url):
    if url not in cache:
        try:
            with urllib.request.urlopen(urllib.request.Request(url, headers={'User-Agent': 'lang-check'})) as response:
                parser = LanguageLinks(response.geturl())
                parser.feed(response.read().decode('utf-8', 'replace'))
                cache[url] = parser.links
        except urllib.error.HTTPError as error:
            cache[url] = error.code
    return cache[url]


for page in sys.argv[1:]:
    for (tag, lang), target in fetch(page).items():
        if lang == 'x-default' or target == page:
            continue
        kind = 'hreflang' if tag == 'link' else 'switcher'
        if urlparse(target).path in HOMES and urlparse(page).path not in HOMES:
            print(f'HOMEPAGE    {page} [{kind} {lang}] -> {target}')
            continue
        back = fetch(target)
        if isinstance(back, int):
            print(f'HTTP {back}    {page} [{kind} {lang}] -> {target}')
        elif page not in back.values():
            print(f'NO RETURN   {page} [{kind} {lang}] -> {target}')

Adapt HOMES to your homepages, then run it on a list of URLs, for example those in one language's sitemap:

curl -s https://example.com/sitemap-fr.xml | grep -o '<loc>[^<]*' | sed 's/<loc>//' | head -200 | xargs python3 check_language_links.py

No output means everything is compliant. The script compares URLs character by character: a trailing slash missing on one side is flagged, which is also an inconsistency to fix.

Other methods:

  • Screaming Frog: enable the storing and crawling of hreflang (Configuration > Spider > Crawl), then open the Hreflang tab. The filters on missing return links reveal the annotations that point to the wrong page.
  • Search Console: the former International Targeting report no longer exists; crawling remains the reference method.

How to implement

Before you start

The underlying rule: a single source of truth connects translations to each other, and both the switcher and the hreflang annotations are generated from it. In practice, each piece of content carries a translation group identifier:

Group fr de en
produit-chaussure-rando /fr/produits/chaussure-rando/ /de/produkte/wanderschuh/ /en/products/hiking-boot/
page-tarifs /fr/tarifs/ /de/preise/ /en/pricing/
article-guide-taille /fr/blog/guide-des-tailles/ missing /en/blog/size-guide/

When the equivalent does not exist, like the German article above, do not replace it with the homepage in the hreflang annotations: simply omit the language. The switcher, on the other hand, can hide the language or offer the parent section with an explicit label. This case is covered in detail in plan for missing translations (opens in a new tab).

Do not compute the target URL by replacing only the prefix (/fr/ with /de/) if your slugs are translated: you would get /de/produits/chaussure-rando/, which does not exist. See translate slugs if relevant (opens in a new tab).

WordPress

Versions WordPress 6.8 and later; Polylang 3, WPML 5 and TranslatePress 3, November 2026.

Multilingual plugins link translations to each other; the switcher points to the equivalent page provided that this link exists.

  • Polylang: in the editor, the “Languages” panel lists the page's translations. A translated page created separately, without going through this panel, is linked to nothing: link it by searching for it in the field for the language concerned. In the menu switcher, leave the option that forces the link to the front page unchecked; in code, keep force_home at its default value, false.
  • WPML: translations created through WPML's translation management are linked automatically. For an existing page created by hand, use the editor's “Language” box and its option to connect it to an existing translation. In WPML > Settings > Language Switchers, under the “How to handle languages without translation” setting, keep “Skip language” (the default) rather than the link to the language's homepage.
  • TranslatePress: a single page translated string by string; the switcher always points to the same page in the other language.
  • Custom theme: look for hard-coded links (grep -rn "href=\"/de/\"" wp-content/themes/) and replace them with the plugin's switcher.

Shopify

Versions Shopify, all plans, Online Store 2.0 themes, November 2026.

The native localization form sends the visitor to the current page in the chosen language: keep it. Problems come from themes or apps that hard-code links to /de or /en. In the theme code (Online Store > Themes > Edit code), look for links containing a fixed language code. If you add crawlable links, build them from the current path, as in provide a crawlable language switcher (opens in a new tab). The hreflang annotations generated by Shopify already connect the equivalent pages.

Drupal

Versions Drupal 10 and 11.

The “Language switcher” block points to the translation of the current entity. The translation still has to be a Drupal translation (the content's “Translate” tab), not a second node created separately: two distinct nodes are not linked by anything, and the switcher then displays the first node under the other language's prefix. Merge these duplicates into translations, then 301-redirect the URL of the deleted node.

Laravel

Versions Laravel 11 to 13, spatie/laravel-translatable 6.

Store slugs per language and compute the equivalent URLs once, for both the hreflang annotations and the switcher. Example with spatie/laravel-translatable:

// app/Models/Page.php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;

class Page extends Model
{
    use HasTranslations;

    /** @var array<int, string> */
    public array $translatable = ['title', 'slug', 'body'];

    /** @return array<string, string> */
    public function alternateUrls(): array
    {
        return collect($this->getTranslations('slug'))
            ->filter(fn (?string $slug): bool => filled($slug))
            ->map(fn (string $slug, string $locale): string => route('pages.show', ['locale' => $locale, 'slug' => $slug]))
            ->all();
    }
}
// app/Http/Controllers/PagesController.php
namespace App\Http\Controllers;

use App\Models\Page;
use Illuminate\View\View;

class PagesController
{
    public function show(string $locale, string $slug): View
    {
        $page = Page::query()->where("slug->{$locale}", $slug)->firstOrFail();

        return view('pages.show', [
            'page' => $page,
            'alternates' => $page->alternateUrls(),
        ]);
    }
}

In the template, the same variable feeds both uses:

{{-- resources/views/layouts/app.blade.php, in the <head> --}}
@foreach($alternates ?? [] as $locale => $url)
    <link rel="alternate" hreflang="{{ $locale }}" href="{{ $url }}">
@endforeach

{{-- in the page header --}}
<nav aria-label="{{ __('Choose a language') }}">
    <ul>
        @foreach($alternates ?? [] as $locale => $url)
            <li><a href="{{ $url }}" hreflang="{{ $locale }}" lang="{{ $locale }}">{{ config("app.locale_names.{$locale}") }}</a></li>
        @endforeach
    </ul>
</nav>

config('app.locale_names') is a key to add in config/app.php, for example ['fr' => 'Français', 'de' => 'Deutsch'].

Next.js

Versions Next.js 15 and 16 (App Router).

With the App Router, a single function provides the equivalent URLs to generateMetadata and to the switcher:

// lib/alternates.ts
const SITE = 'https://example.com';

type Translation = { lang: string; slug: string };

export async function getAlternates(translationKey: string): Promise<Record<string, string>> {
  const translations: Translation[] = await fetch(`${process.env.CMS_URL}/translations/${translationKey}`).then((res) => res.json());

  return Object.fromEntries(translations.map(({ lang, slug }) => [lang, `${SITE}/${lang}/${slug}/`]));
}
// app/[lang]/[slug]/page.tsx
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { LanguageSwitcher } from '@/components/language-switcher';
import { getAlternates } from '@/lib/alternates';
import { getPage } from '@/lib/cms';

type Props = { params: Promise<{ lang: string; slug: string }> };

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { lang, slug } = await params;
  const page = await getPage(lang, slug);

  if (!page) {
    notFound();
  }

  const alternates = await getAlternates(page.translationKey);

  return { alternates: { canonical: alternates[lang], languages: alternates } };
}

export default async function Page({ params }: Props) {
  const { lang, slug } = await params;
  const page = await getPage(lang, slug);

  if (!page) {
    notFound();
  }

  const alternates = await getAlternates(page.translationKey);

  return (
    <>
      <LanguageSwitcher current={lang} alternates={alternates} />
      <h1>{page.title}</h1>
    </>
  );
}

Next.js memoizes identical fetch requests between generateMetadata and the page: the CMS is only called once.

Nuxt

Versions Nuxt 3 and 4, @nuxtjs/i18n module 10.

With @nuxtjs/i18n and translated slugs, declare each language's parameters in the page; useSwitchLocalePath() and the hreflang annotations generated by the module then use them:

<!-- pages/products/[slug].vue -->
<script setup lang="ts">
const route = useRoute();
const { data } = await useFetch(`/api/products/${route.params.slug}`);
const setI18nParams = useSetI18nParams();

setI18nParams({
  fr: { slug: data.value?.slugs.fr },
  de: { slug: data.value?.slugs.de },
  en: { slug: data.value?.slugs.en },
});
</script>

Without this declaration, the module does not know the German slug of a French product.

Astro

Versions Astro 5 to 7.

Add a shared translation key to the front matter of each piece of content (translationKey: guide-tailles), then group them:

---
// src/pages/[lang]/[slug].astro
import { getCollection } from 'astro:content';
import LanguageSwitcher from '../../components/LanguageSwitcher.astro';

export async function getStaticPaths() {
  const pages = await getCollection('pages');

  return pages.map((page) => {
    const alternates = Object.fromEntries(
      pages
        .filter((other) => other.data.translationKey === page.data.translationKey)
        .map((other) => [other.data.lang, `/${other.data.lang}/${other.data.slug}/`]),
    );

    return { params: { lang: page.data.lang, slug: page.data.slug }, props: { page, alternates } };
  });
}

const { page, alternates } = Astro.props;
---
<LanguageSwitcher current={page.data.lang} alternates={alternates} />

The switcher component loops over alternates, and the template writes the hreflang annotations from the same object.

Webflow

Versions Webflow with Localization, November 2026.

Use the “Locales list” element and links of the page or collection page type: Webflow then routes to the equivalent page in each language. A link entered as a direct URL is not routed.

Common mistakes

  • A language link hard-coded to /de/ in the theme header.
  • hreflang on every page pointing to the homepage of each language: non-reciprocal annotations, ignored.
  • A translation created as a standalone page in the CMS, never linked to the original.
  • Replacing only the prefix when slugs are translated: links to 404 pages.
  • An approximate equivalent in the hreflang annotations: a product page annotated toward a category. A parent section can help out in the switcher, never in the annotations.
  • A target that redirects: the equivalent page has changed URL and the link still points to the old one.
  • Lost parameters: the switcher on a filtered or paginated page leads to the first page without warning. Acceptable if intended, to be checked otherwise.

Frequently asked questions

Can the language switcher lead to each language's homepage?

It should be avoided. A visitor who changes language on a product page or an article wants to read the same page in the other language; sending them to the homepage forces them to search for everything again and leads to drop-offs. The switcher must point to the equivalent page. The homepage is only acceptable for a language in which the page does not exist, with a label that says so clearly.

Can hreflang annotations point to the homepage?

Only from the homepage, or for the x-default value designating a language selection page. A deep page must annotate its exact equivalents. Google requires reciprocal annotations: a product page that names the German homepage receives no return link, and its annotations are ignored. If the equivalent does not exist, omit the language rather than pointing to the homepage.

How can you check that the switcher points to the right pages across the whole site?

Test one page of each template by hand, then automate. A Screaming Frog crawl with hreflang crawling enabled flags missing return links. A script that reads the language links and hreflang annotations for each URL in the sitemap, then checks that no target is a homepage and that each one links back to the starting page, catches the rest.

Updated on

Topic checklist (PDF)

And now?

In the “International architecture” topic

  1. Define target languages
  2. Define target countries
  3. Distinguish language from geotargeting
  4. Choose subdirectories, subdomains or country-code domains
  5. Plan a separate URL for each language version
  6. Translate slugs if relevant
  7. Avoid handling language only through cookies/JS
  8. Avoid forced IP-based redirects
  9. Avoid forced redirects based on browser language
  10. Provide a crawlable language switcher
  11. Link to the equivalent page rather than the homepage
  12. Plan for missing translations
  13. Check URL structure consistency
  14. Define the default version
  15. Avoid mixed-language pages with partial translations