Nightcrop
LoginJoin the waitlist

Canonical URL: What It Is and How to Set One

Nightcrop · October 26, 2026

A canonical URL is the one address you want search engines to treat as the main version of a page when the same or very similar content lives at several URLs. You set it with a rel="canonical" link in the page head, a redirect, or a sitemap entry. Google treats it as a hint, not a command.

Why do duplicate URLs happen?

Most duplicates are accidental. One product page can be reachable with and without a trailing slash, over http and https, with tracking parameters, with sort or filter parameters, and through a print or mobile path. To a person these are one page. To a crawler they are separate addresses with near identical content.

Google's documentation on consolidating duplicate URLs describes canonicalization as picking the representative URL from a set of duplicates, so that signals and reporting gather in one place. Without a clear choice, Google picks for you, and it may not pick the one you would.

What are the ways to signal a canonical?

Google lists several methods and ranks how strongly each one nudges the choice.

MethodStrength, per GoogleUse it when
301 redirectStrong signalYou are retiring the duplicate and nobody needs it
rel="canonical" link (HTML head or HTTP header)Strong signalThe duplicate must stay reachable, such as a filtered view
Listing the URL in your sitemapWeak signalAs a backup that agrees with the other two

Google also says these methods can stack and work better combined. The practical rule is that all of them should point to the same URL. If your sitemap lists one version and your canonical tag names another, you have given conflicting instructions and the outcome is a guess. For the redirect side of this, see 301 vs 302 redirects.

How do you add a rel="canonical" tag?

Put one link element inside the head of the page:

  1. Choose the preferred URL, with the protocol and host you actually serve, for example https://example.com/shoes/red-trainers.
  2. Add <link rel="canonical" href="https://example.com/shoes/red-trainers"> to the head of that page and of every duplicate of it.
  3. Use the full absolute URL, not a relative path.
  4. Check the page source, not just the rendered page, to confirm the tag is there once.

Google states that the element is only accepted if it appears in the head of the HTML. A canonical tag dropped into the body is ignored. For non-HTML files such as PDFs, the HTTP header version is available instead.

What mistakes break canonicals?

Should every page have a self-referencing canonical?

Yes, it is a cheap habit. Google's guidance includes adding a canonical link to the canonical page itself. It protects a page from picking up a stray parameter version, such as one with a tracking tag, as a rival.

How do you check which URL Google chose?

Your declared canonical and the one Google selects can differ. Open the URL Inspection tool in Search Console and read the "User-declared canonical" and "Google-selected canonical" fields. If they differ, look for conflicting signals: a sitemap listing another version, internal links to a parameter URL, or content that is not as similar as you thought. Our guide to checking whether a page is indexed covers that tool in more detail.

If a page shows as a duplicate whose canonical Google chose differently, fix the signals first. Then request a recheck. Do not assume the tag is broken until the signals agree.

How does this relate to your sitemap?

A sitemap should list only the canonical version of each page. Listing duplicates sends a mixed message. If you are unsure whether you need one at all, read whether you need an XML sitemap.

A short checklist

  1. Pick one preferred URL per page: https, one host version, one slash style.
  2. Redirect true duplicates to it.
  3. Add a self-referencing canonical in the head of every page.
  4. Keep sitemap entries and internal links pointed at the same URL.
  5. Spot check with URL Inspection after any template or parameter change.

Frequently Asked Questions

Is a canonical tag a directive?

No. Google treats it as a strong signal and may choose another URL if the signals conflict.

Can a page canonicalize to itself?

Yes, and it is recommended. A self-referencing canonical names the page as its own preferred version.

Should I use a canonical tag or a 301 redirect?

Use a redirect when the duplicate should disappear. Use a canonical tag when both URLs must stay reachable.

Does the canonical tag go in the body?

No. It is only accepted in the head of the HTML, or sent as an HTTP header.

Can I block duplicate pages in robots.txt instead?

That is not advised for this purpose. Google may still index a blocked URL without its content, and it cannot read a canonical tag on a page it cannot crawl.