Home / Knowledge base / Glossary / Canonical URL: how to set it for a page and check it

Canonical URL: how to set it for a page and check it

Glossary 7 min read Updated 18.10.2026
To set a canonical URL, add a link rel="canonical" tag with the full URL of the main version to the page's <head>; for PDFs and other files, use the HTTP Link header. Below: four methods, code examples, CMS setup, common mistakes and how to see which URL Google chose.

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

MethodWhere it goesSignal strength per Google's documentationWhen to use it
link rel="canonical" tagIn the <head> of an HTML pageStrongThe default for ordinary pages
HTTP Link headerIn the server responseStrong (the same annotation as the tag)PDFs, documents and other files without a <head>
301 redirectOn the serverStrongWhen people no longer need the duplicate — see 301 vs 302
SitemapList only the preferred URLs in sitemap.xmlWeakAn 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 Link header, 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 noindex for 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

CaseWhat to Specify
Regular PageItself — self-canonical
Address with UTM TagsClean address without parameters
PaginationEach page to itself, not all to the first
One Product in Several CategoriesOne main product address
Print VersionMain version
Canonical Address Is a Hint, Not a Command
Google considers it along with other signals: internal links, sitemap, redirects. If they contradict each other, the search engine will choose the canonical page itself — and not always the one you specified.

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.

  1. Keep the default self-referencing canonical on all ordinary pages.
  2. For duplicates — a product in several categories, a print version — enter the main version's URL in the field.
  3. After installing a plugin, check that the page has only one tag: themes and plugins often both output it.
  4. 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

  1. Page source. Open the page, press Ctrl+U and search for canonical: there should be one tag, inside the <head>.
  2. 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.
  3. The index checker compares the canonical with the final URL after redirects and warns when they differ.
  4. 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.
  5. 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”.

FAQ

Is Google obliged to follow canonical?
No, it is a hint. The search engine considers it along with internal links, the sitemap, and redirects and may choose another canonical page.
What to specify on pagination pages?
Each page to itself. Pointing all pages to the first one drops the second and further from the index.
Can canonical and noindex be set together?
It is not advisable: these are conflicting signals, and the result will be unpredictable.
How do I set a canonical URL for a page?
Add a link element with rel="canonical" and the absolute URL of the main version to the page head. For PDFs and other non-HTML files, use an HTTP Link header with rel="canonical".
Should a page have a self-referencing canonical?
Yes, it is good practice: a self-referencing canonical protects the main page from duplicates created by tracking parameters, sorting options and other URL variants.
Can a canonical URL be relative?
Technically yes, but Google recommends absolute URLs with protocol and domain, which removes the risk of the address being resolved incorrectly.
Where can I see which canonical Google chose?
In Search Console URL Inspection: it shows the user-declared canonical and the Google-selected canonical side by side.
Was this article helpful?
Try it on your project Everything described in the article is available in the dashboard — the registration bonus is already in your balance.
Open dashboard