In short
The canonical tag says which URL represents a page; hreflang annotations say which URLs represent its other languages. Both must point to exactly the same addresses. In practice, each language version carries a canonical to itself, and each hreflang annotation lists the canonical URL of the target version, character for character: protocol, subdomain, trailing slash, parameters. Once the task is done, no version declares itself a duplicate of another language, and no annotation points to a URL that its own page disowns.
Why it matters
Google processes the two signals together. Its canonicalization documentation asks that, when you use hreflang, you specify a canonical page in the same language, or in the closest substitute language if the same language does not exist. It also states that, for canonicalization, Google prefers URLs that are part of an hreflang group.
Two conflicts keep coming up:
- A translation canonicalized to the main language. The German page declares the French page as canonical. It therefore presents itself as a duplicate: Google selects the French URL and the
deannotation points to a page that disowns itself. The German version may not be indexed under its own URL (see do not canonicalize all translations to the main language (opens in a new tab)). - An annotation pointing to a non-canonical variant. The annotation lists
http://example.com/de/preisewhile the page's canonical ishttps://example.com/de/preise/. These are two different URLs: Google has to connect the variant to the canonical to rebuild the group.
One case remains outside your control: when two regional variants are almost identical (fr-FR and fr-BE with the same text), Google may choose one as canonical for both. Google's John Mueller explained in 2025 that hreflang could still show the right URL in the results, but that the reports focused on the canonical URL. See handle near-identical regional variants (opens in a new tab).
What it improves
- Indexing of each language under its own URL, instead of consolidation into the main language.
- hreflang groups taken into account The annotations list the URLs Google selects.
- Readable reports Each version's impressions and clicks appear under the right URL in Search Console.
- Generative engines Indirect effect. AI crawlers publish no rules about hreflang, but a stable canonical URL per language limits the duplicates they come across.
- Rankings No direct effect.
How to check
1. On a group of pages, without paid tools. This Python script reads a page's annotations, then checks for each version that its canonical is identical to the announced URL:
#!/usr/bin/env python3
"""Usage: python3 hreflang_canonical.py https://example.com/fr/tarifs/"""
import sys
import urllib.request
from html.parser import HTMLParser
class HeadParser(HTMLParser):
def __init__(self):
super().__init__()
self.alternates = {}
self.canonical = None
def handle_starttag(self, tag, attrs):
attributes = {name.lower(): (value or '') for name, value in attrs}
rel = attributes.get('rel', '').lower()
if tag == 'link' and rel == 'alternate' and 'hreflang' in attributes:
self.alternates[attributes['hreflang'].lower()] = attributes.get('href', '')
elif tag == 'link' and rel == 'canonical':
self.canonical = attributes.get('href', '')
def parse(url):
request = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0 (audit hreflang)'})
with urllib.request.urlopen(request, timeout=20) as response:
parser = HeadParser()
parser.feed(response.read().decode('utf-8', 'replace'))
return parser
source = parse(sys.argv[1])
for hreflang, url in sorted(source.alternates.items()):
page = parse(url)
problems = []
if page.canonical != url:
problems.append(f'canonical = {page.canonical}')
if page.alternates != source.alternates:
problems.append('annotations differ from the source page')
print(f"{'OK ' if not problems else 'ALERT '} {hreflang:10} {url} {'; '.join(problems)}")
Expected result: one OK line per version. A canonical = https://example.com/fr/tarifs/ line on the German version signals a translation canonicalized to French.
2. Across the whole site. In Screaming Frog, with hreflang crawling enabled (Configuration > Spider > Crawl), two filters in the Hreflang tab cover this task: “Not Using Canonical” (the page does not announce itself under its canonical URL) and “Non-Canonical Return Links” (annotations point to non-canonical URLs). Cross-check with the Canonicals tab.
3. From Google's point of view. In Search Console's URL Inspection tool, compare “User-declared canonical” and “Google-selected canonical” for one page in each language. A German version whose selected canonical is the French URL signals a conflict. The Page indexing report also lists the reasons “Alternate page with proper canonical tag” and “Duplicate, Google chose different canonical than user”. See compare declared and Google-selected canonicals (opens in a new tab).
How to implement
Before you start
The rules to apply:
| Page | Canonical | hreflang annotations |
|---|---|---|
Canonical language version (/de/preise/) |
To itself | All versions, exact canonical URLs |
Parameter variant (/de/preise/?utm_source=x) |
To /de/preise/ |
None, or an exact copy of those of /de/preise/ |
Page 2 of a paginated list (/de/blog/seite/2/) |
To itself | The page 2s of the other languages if pagination is identical, otherwise none |
| Near-identical regional variant | To itself | All variants; differentiate the content (currency, delivery, contact) |
x-default fallback version |
To itself | Like the other versions |
Details that create discrepancies:
- URL form: same protocol, same subdomain, same trailing slash, same case in the canonical, the annotations and the sitemap (see use absolute URLs (opens in a new tab)).
- No
hreflangattribute on the canonical tag: Google states thatrel="canonical"links carrying anhreflang,lang,mediaortypeattribute are not used for canonicalization. - A single canonical per page, in the
<head>. Two contradictory tags (theme plus plugin) cancel the signal.
HTML
Compliant German page:
<link rel="canonical" href="https://example.com/de/preise/">
<link rel="alternate" hreflang="de-DE" href="https://example.com/de/preise/">
<link rel="alternate" hreflang="fr-FR" href="https://example.com/fr/tarifs/">
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/pricing/">
<link rel="alternate" hreflang="x-default" href="https://example.com/uk/pricing/">
The de-DE line and the canonical carry exactly the same URL. On the French page, the canonical points to /fr/tarifs/ and the hreflang block is identical.
XML sitemap
Each entry's <loc> value is the page's canonical URL, and the same URL appears in its own xhtml:link link:
<url>
<loc>https://example.com/de/preise/</loc>
<xhtml:link rel="alternate" hreflang="de-DE" href="https://example.com/de/preise/"/>
<xhtml:link rel="alternate" hreflang="fr-FR" href="https://example.com/fr/tarifs/"/>
</url>
Do not list in the sitemap a URL whose canonical points elsewhere.
Apache
Versions Apache 2.4.
For PDFs annotated through headers, the canonical also goes through the Link header. Each file declares itself canonical:
<Files "preise.pdf">
Header set Link "<https://example.com/docs/preise.pdf>; rel=\"canonical\", <https://example.com/docs/preise.pdf>; rel=\"alternate\"; hreflang=\"de\", <https://example.com/docs/tarifs.pdf>; rel=\"alternate\"; hreflang=\"fr\""
</Files>
Reload with sudo apachectl configtest && sudo systemctl reload apache2.
Nginx
Versions Nginx 1.24 and later.
location = /docs/preise.pdf {
add_header Link '<https://example.com/docs/preise.pdf>; rel="canonical", <https://example.com/docs/preise.pdf>; rel="alternate"; hreflang="de", <https://example.com/docs/tarifs.pdf>; rel="alternate"; hreflang="fr"';
}
Reload with sudo nginx -t && sudo systemctl reload nginx.
WordPress
Versions WordPress 6.8 and later; Yoast SEO 28, Rank Math 1.0, WPML 4 and 5, Polylang 3.
The annotations come from the multilingual plugin, the canonical from WordPress or the SEO plugin: both must produce the same URL.
- Yoast SEO and Rank Math output a canonical to each translation's permalink by default, which is correct. The conflict arises from a custom canonical entered in the original's
Advancedtab and then copied into the translations. - WPML: in
WPML > Settings, Custom Fields Translation section (in WPML 4 as in WPML 5), set_yoast_wpseo_canonical(Yoast) orrank_math_canonical_url(Rank Math) to “Don't translate” or “Translate”, never “Copy”. Check the result in a translation's source code. - Polylang: each translation has its own SEO settings; check that no custom canonical points to the main language.
- Site address:
Settings > General, usinghttps://and the final form, so that the canonical and the annotations share the same prefix.
Clear the page cache and check the source code of one page per language.
Shopify
Versions Shopify with Shopify Markets, all plans, November 2026.
Automatic: each localized version gets a canonical to itself, and hreflang annotations link the versions. The theme must output the canonical with the dedicated Liquid object, in layout/theme.liquid:
<link rel="canonical" href="{{ canonical_url }}">
Delete any canonical that is hard-coded or built with the primary domain: it would send every language back to the same URL. If you manage the annotations yourself, Shopify's documentation requires each localized URL to reference itself as its own canonical.
Drupal
Versions Drupal 10 and 11; Metatag 2.x.
With the Metatag module, the default canonical ([node:url] or [current-page:url]) follows the displayed translation: each language references itself. Check in Configuration > Search and metadata > Metatag that no default value forces a URL in the source language, and that only one module produces the hreflang annotations (core, the Hreflang module or a Metatag submodule).
Laravel
Versions Laravel 11 to 13.
Build the canonical and the annotations from the same function, so that they cannot diverge:
{{-- resources/views/components/seo-alternates.blade.php --}}
@props(['alternates', 'currentHreflang'])
<link rel="canonical" href="{{ $alternates[$currentHreflang] }}">
@foreach($alternates as $hreflang => $url)
<link rel="alternate" hreflang="{{ $hreflang }}" href="{{ $url }}">
@endforeach
$alternates comes from the method that lists the published translations (see exclude redirects and nonexistent pages (opens in a new tab)), and route() produces every URL with the same root. On pages with sorting or tracking parameters, the canonical remains that of the page without parameters.
Next.js
Versions Next.js 15 and 16 (App Router).
Define canonical and languages together, page by page:
// app/[locale]/pricing/page.tsx
import type { Metadata } from 'next';
const paths: Record<string, string> = {
'de-DE': '/de/preise/',
'fr-FR': '/fr/tarifs/',
'en-GB': '/uk/pricing/',
};
const hreflangByLocale: Record<string, string> = { de: 'de-DE', fr: 'fr-FR', uk: 'en-GB' };
type Props = { params: Promise<{ locale: string }> };
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { locale } = await params;
return {
metadataBase: new URL('https://example.com'),
alternates: {
canonical: paths[hreflangByLocale[locale]],
languages: { ...paths, 'x-default': paths['en-GB'] },
},
};
}
Two pitfalls specific to Next.js: an alternates defined in a layout is inherited by every page that does not redefine its own, which gives the whole site the home page's canonical; and the trailingSlash option must match the form written in canonical and languages.
Common mistakes
- Canonicalizing all translations to the main language: the other languages declare themselves duplicates.
- Form discrepancies between canonical and annotations:
httpversushttps,wwwor not, trailing slash, capital letters. - Copying the original's canonical into the translations through the multilingual plugin.
- Annotations on parameter pages that point to other parameter pages.
- A canonical inherited from a parent template (Next.js layout, theme template), identical for every page.
- Two canonical tags on the same page, set by the theme and by a plugin.
- Adding
hreflangto the canonical tag: Google does not use it for canonicalization.
Frequently asked questions
Should a translation's canonical point to the original version?
No. Each translation must carry a canonical to itself. A translation canonicalized to the original language declares itself a duplicate of it: Google selects the original URL and the translation may not be indexed under its own address. With hreflang, Google asks you to specify a canonical in the same language. Only true duplicates within one language, such as parameter URLs, point to another page.
Must the URLs in hreflang annotations be identical to the canonicals?
Yes, character for character: same protocol, same subdomain, same trailing slash, same case and no superfluous parameters. An annotation that lists a non-canonical variant forces Google to connect that variant to the URL it selects, which weakens the group. The safest approach is to build the canonical and the annotations with the same function, from the same data.
Why does Google choose my fr-FR page as canonical for fr-BE?
When two regional variants of the same language have almost identical content, Google may treat them as duplicates and keep only one as canonical, despite self-referencing canonicals. Google's John Mueller said that hreflang could still show the right URL in that case, but that the reports focused on the canonical. Genuinely differentiating the content, with the currency, delivery and local contact details, reduces this clustering.
Should parameter pages carry hreflang annotations?
It is not necessary. A page with sorting or tracking parameters carries a canonical to the page without parameters, and it is that canonical page that must carry the annotations. If your template adds them anyway, they must be an exact copy of the canonical page's annotations, with canonical URLs, never parameter variants in other languages.
Resources
- Google Search Central: specify a canonical URL (rel=canonical and other methods)developers.google.com
- Google Search Central: localized versions of your pagesdevelopers.google.com
- Search Console Help: URL Inspection toolsupport.google.com
- Search Engine Roundtable: hreflang does not guarantee indexing (John Mueller, 2025)seroundtable.com
- Shopify: international SEO for marketshelp.shopify.com
- Shopify for developers: hreflang tags in the themeshopify.dev
- Next.js: alternates metadatanextjs.org
Updated on
Topic checklist (PDF)