⌕ Technical SEO

Rel canonical: how to point to the main version of a page

How the canonical tag works, why it is a hint rather than an order, which signals confirm or contradict it and the most frequent technical mistakes.

Almost every site publishes the same content at several addresses, often without knowing it. A product page reachable from two categories, an article with and without tracking parameters, a page with and without a trailing slash. The canonical tag tells the engine which of these versions to treat as the main one, so that signals and visibility concentrate on a single URL.

The syntax

The canonical is declared in the <head>:

<link rel="canonical" href="https://example.com/shoes/leather-boots/">

or, for non-HTML files such as PDFs, with an HTTP header:

Link: <https://example.com/guides/manual.pdf>; rel="canonical"

The URL should be absolute. Relative URLs are technically accepted, but they open the door to mistakes when the same template is served from different hosts, such as staging and production.

A hint, not a command

Unlike noindex, which engines respect, the canonical is a hint. The engine weighs it against other signals and may choose a canonical different from the declared one. The signals that carry the most weight are:

  • redirects, the strongest signal of all;
  • internal links: if the whole site links to version A but the canonical points to B, there is a contradiction;
  • inclusion in the sitemap;
  • the HTTPS protocol over HTTP;
  • the real similarity of the content.

When the engine ignores the canonical, it is usually because the other signals tell a different story. The solution is not to insist with the tag, but to align everything: internal links, sitemap, redirects and canonical must all point to the same URL.

The self-referencing canonical

It is good practice for every indexable page to declare itself as canonical. It protects against duplicates generated by external parameters: if someone links to the page adding ?utm_source=..., the canonical brings the signals back to the clean address. The same applies to copies of the site served by proxies, automatic translators or aggregators that republish the HTML as it is: the self-referencing tag travels with the content and still points to the original.

When to use a canonical and when not to

Situation Suitable tool
Same content with tracking parameters canonical to the clean URL
Product in several categories canonical to a single path
Page permanently moved 301 redirect, not canonical
Page to exclude from the index noindex, not canonical
Language variants hreflang, each canonical to itself
Pages in a paginated series each canonical to itself

The last point is a widespread mistake: setting the canonical of every page in a paginated list to the first one. That way the content of the following pages, and the links to the products they contain, risk being disregarded.

The most common technical mistakes

Canonical pointing to non-indexable pages

The declared canonical must return 200, be indexable and not redirect. A canonical pointing to a 404, to a URL with noindex or to an address that redirects elsewhere is a broken signal.

Multiple canonicals

Two canonical tags on the same page, perhaps one from the theme and one from a plugin, with different values: faced with ambiguity, the engine may ignore both.

Canonical in the wrong place

The tag must be in the <head>. If it ends up in the <body>, for example because a script inserts it after an element that closes the head early, it is ignored.

Canonical changed by JavaScript

If the initial HTML declares one canonical and JavaScript changes it afterwards, the engine receives two versions. It is better to have it right from the start.

Canonical between different content

Using the canonical to «merge» pages that are not duplicates, such as two similar but distinct articles, does not work: the engine recognises the difference and ignores the hint.

How to check it

  1. Check the canonical in the initial HTML and in the rendered DOM.
  2. Verify that the canonical URL returns 200 and has no noindex.
  3. Use the URL inspection in webmaster tools to compare the declared canonical with the one chosen by the engine.
  4. With a crawler, look for pages whose canonical points elsewhere but which receive many internal links: these are inconsistencies to fix.

In short

  • The canonical indicates the main version among duplicate content.
  • It is a hint: redirects, internal links and sitemap must confirm it.
  • Every indexable page should have a canonical pointing to itself.
  • Do not use it instead of redirects, noindex or hreflang.
  • The canonical target must return 200, be indexable and be unique.
MM
Marco Marzaduri

Marco Marzaduri works in cybersecurity, digital forensics and web development. A computer science graduate, he combines rigorous technical analysis with attention to the people who use technology.

Read also