Canonical URL: how to set it for a page and check it
To set a canonical URL, add <link rel="canonical" href="https://example.com/main-page/"> with the full URL of the main version to the page's <head>; for PDFs and other non-HTML files, send an HTTP Link header instead. A canonical URL tells search engines which of several identical or similar addresses to treat as the main one. Google treats it as a strong signal, not a binding command.
Why It Is Necessary
The same material is often available at several addresses: with sorting parameters and tags, with www and without, with a slash at the end and without it, in a print version. For search, these are different pages with the same content. The canonical address combines them: signals and link weight are consolidated into one version, and it is this one that appears in the search results.
How to set a canonical URL: four methods
| Method | Where it goes | Signal strength per Google's documentation | When to use it |
|---|---|---|---|
link rel="canonical" tag | In the <head> of an HTML page | Strong | The default for ordinary pages |
HTTP Link header | In the server response | Strong (the same annotation as the tag) | PDFs, documents and other files without a <head> |
| 301 redirect | On the server | Strong | When people no longer need the duplicate — see 301 vs 302 |
| Sitemap | List only the preferred URLs in sitemap.xml | Weak | An extra signal, not a replacement for the tag |
The HTML tag
<head>
<link rel="canonical" href="https://example.com/catalog/sofas/">
</head>
The HTTP header for a PDF
Link: <https://example.com/docs/price.pdf>; rel="canonical"
In nginx you add it in the location block for that file:
location = /files/price-2026.pdf {
add_header Link '<https://example.com/docs/price.pdf>; rel="canonical"';
}
To confirm the header is actually sent, use the HTTP headers checker, which lists every response header.
Rules for writing the canonical tag
- Absolute URL with protocol and domain. Google recommends absolute URLs:
https://example.com/page/, not/page/. - Only in the
<head>. Google does not accept the tag in the body. If the template outputs an invalid element earlier, the<head>can close early and push the tag into the body. - One canonical per page. Two tags with different URLs, or a tag that contradicts the
Linkheader, send conflicting signals. - Match the version you promote: same protocol, same host (with or without www), same trailing slash.
- The target returns 200, is indexable and is not blocked in robots.txt.
- Self-referencing canonical on main pages protects them from duplicates created by tracking parameters.
- No robots.txt or removal tool. Google says not to use them for canonicalization and does not recommend
noindexfor choosing a canonical within one site. - Prefer the raw HTML. Google can process a tag injected by JavaScript after rendering, but many tools and crawlers do not run scripts.
How Proper Setup Looks
| Case | What to Specify |
|---|---|
| Regular Page | Itself — self-canonical |
| Address with UTM Tags | Clean address without parameters |
| Pagination | Each page to itself, not all to the first |
| One Product in Several Categories | One main product address |
| Print Version | Main version |
How to set a canonical URL in WordPress and other CMSs
In most CMSs the tag comes from the theme or an SEO module, not from the page editor. WordPress usually outputs a canonical tag on posts and pages already; SEO plugins such as Yoast SEO and Rank Math extend it to other page types and add a field for a custom canonical URL in the post's advanced settings. In other systems, look for a similar field in the page's SEO settings or a meta-tag module; on a custom site, add the tag to the shared <head> template using the current page URL without parameters.
- Keep the default self-referencing canonical on all ordinary pages.
- For duplicates — a product in several categories, a print version — enter the main version's URL in the field.
- After installing a plugin, check that the page has only one tag: themes and plugins often both output it.
- Pagination and filters have their own rules — see pagination and faceted navigation.
Canonical URLs on multilingual sites and separate mobile versions
Language versions are not duplicates, even when the translation is close. Each version should have a canonical URL pointing to itself, and the relationship between languages is described with hreflang. If the English page names the Russian page as canonical, Google may drop the English page from the index, and the hreflang markup stops working because it must reference canonical URLs only.
<!-- on https://example.com/en/page/ -->
<link rel="canonical" href="https://example.com/en/page/">
<link rel="alternate" hreflang="ru" href="https://example.com/page/">
<link rel="alternate" hreflang="en" href="https://example.com/en/page/">
A separate mobile site on a subdomain such as m.example.com is a different case: for those sites Google describes a pair of annotations — rel="alternate" on the desktop page and rel="canonical" from the mobile page back to the desktop page. A responsive site with one URL for all devices needs none of this. More in hreflang, checking hreflang and mobile-first indexing.
Common Mistakes
- All pages point to the main one. A classic mistake when copying a template: other pages drop out of the index.
- The canonical address leads to a redirect or 404. The signal is completely broken.
- Different protocols and domains. The address must match the one you are actually promoting.
- Canonical plus noindex on the same page. A contradiction that is interpreted unpredictably.
How to check a canonical URL
- Page source. Open the page, press Ctrl+U and search for
canonical: there should be one tag, inside the<head>. - The meta tag analyzer shows the canonical next to the title, description and hreflang. It reads raw HTML without running JavaScript, so it will not see a tag added by a script.
- The index checker compares the canonical with the final URL after redirects and warns when they differ.
- Search Console → URL Inspection. The indexing details show two fields: user-declared canonical and Google-selected canonical. If they differ, Google did not accept your hint.
- Page indexing report. The status Duplicate, Google chose different canonical than user lists those URLs.
If Google picks a different URL, look for conflicting signals: internal links to the duplicate, the duplicate in the sitemap, a redirect in the opposite direction, different content on "identical" pages. More in how to check if a page is indexed.
Canonical Address vs. Redirect
They are often confused. A redirect physically takes both the bot and the user to another address — the old page stops opening. A canonical address keeps both pages accessible but asks to consider one of them as the main one. The rule is simple: if the old address is no longer needed by users — redirect; if both versions are needed, for example, a product in two categories — canonical address.
How It Relates to Promotion
Links should lead to the canonical address. If the promoted page specifies another address as canonical, the weight will go there, not to it. You can check the tags with the meta tag analyzer, and the choice of the page for launch is discussed in the article “Which Page to Choose”.