Canonicalisation in SEO means choosing the preferred URL for duplicate or very similar content and giving search engines consistent signals about that choice. Check 3 things together: the content relationship, the declared preferred URL and the signals elsewhere on the site. A canonical tag expresses a preference; it does not force Google to select that address.
When should you use a canonical URL rather than a redirect?
Imagine a fictional workshop business whose service page is available at https://example.com/workshops/ and at the same address with a campaign parameter. If both versions show the same service information, the clean address is a sensible preferred URL. The campaign address can remain usable for visitors while pointing to the clean page through a canonical annotation. This is an editorial example, not an observation about a live business.
Start by checking the pages themselves. Two pages sharing a logo, navigation and footer are not necessarily duplicates. A workshop overview and a detailed booking-policy page answer different questions. Pointing both at the overview would ask the search engine to consolidate content that the business actually wants people to find separately. Fix the content relationship before choosing a technical mechanism.
Google’s canonical URL documentation distinguishes strong redirect and canonical-link signals from weaker sitemap inclusion. These methods can reinforce one another. They can also conflict: declaring one address in the page while listing another as preferred in the sitemap gives the search engine inconsistent guidance.
Use a redirect when the old duplicate should cease to be an independent destination. For example, a retired service address might send visitors to its replacement. Keep a canonical annotation when an alternative address still needs to serve substantially the same content. This distinction affects visitors as well as crawlers: a redirect changes where the request lands, while a canonical annotation can leave the requested page visible.
For an HTML duplicate, put the annotation in the document’s head:
<link rel="canonical" href="https://example.com/workshops/">
Google recommends absolute URLs and a self-referential annotation on the preferred page itself. Use the full intended scheme, hostname and path. Avoid treating a relative link as harmless merely because it appears to work on a developer’s machine; deployment and staging contexts can change its interpretation.
Non-HTML files need different handling. Google documents a canonical Link HTTP response header for supported documents such as PDFs. An HTML element copied into a PDF is not that response header. Where a document is available in different formats, decide which version should represent it and ask the site operator to configure the relevant response, rather than adding an unrelated page-level setting.
Do not use robots.txt as a canonical selector. Google warns that a disallowed URL can still be indexed without its content. It also advises against using noindex merely to influence canonical selection within a site, because that directive blocks the page from Search. Access, indexing and preferred representation are different decisions.
How can you check a preferred URL without pretending to control Google’s choice?
Make a small URL-family record before changing templates. For each address, note its purpose, whether visitors still need it, its canonical annotation, any redirect target, sitemap inclusion and the internal links pointing to it. The following worked example is a proposed configuration for the fictional workshop site.
| Address or signal | Intended treatment | Reason |
|---|---|---|
/workshops/ |
Self-referential canonical | Preferred service explanation |
/workshops/?campaign=notice |
Canonical to clean workshop URL | Same content remains usable with campaign context |
/old-workshops/ |
Permanent redirect to replacement | Retired destination should move visitors |
/workshop-booking-policy/ |
Retain its own identity | Distinct policy content, not a duplicate |
| Sitemap and navigation | Use the clean preferred service URL | Avoid competing preference signals |
Check the rendered page as well as the template setting. Google’s troubleshooting guidance identifies CMS mistakes, redirects and server misconfiguration as possible causes of an unexpected selection. A setting labelled “canonical URL” is not proof that the final document contains the intended annotation.
Original worked example: a deliberately limited local canonical check. Save it as check_canonical.py and run python3 check_canonical.py. It parses an embedded fictional HTML string and makes no network request:
from html.parser import HTMLParser
class Canonicals(HTMLParser):
def __init__(self):
super().__init__()
self.urls = []
def handle_starttag(self, tag, attrs):
a = dict(attrs)
if tag == "link" and "canonical" in a.get("rel", "").split():
self.urls.append(a.get("href"))
page = '<head><link rel="canonical" href="https://example.com/workshops/"></head>'
parser = Canonicals()
parser.feed(page)
assert parser.urls == ["https://example.com/workshops/"]
print("Fixture canonical matches the intended URL")
This exact fixture was executed during drafting and produced the displayed success message. It establishes only that the embedded example contains the expected link. It does not fetch a website, validate the whole HTML document, inspect HTTP headers or determine any search engine’s selected canonical. Replacing the string with a saved page can help inspect that file, but a developer still needs to check response behaviour and generated output separately.
For a site you are authorised to manage, use Search Console’s URL Inspection tool to inspect Google’s selected canonical. Compare it with your declared preference and ask whether the selected page is actually a better representative. Google can choose differently even when you provide an explicit annotation. A difference is a diagnostic finding, not automatic evidence of a penalty or an instruction to remove every alternative URL.
Record the cause and the correction together. If navigation points at the campaign URL, change those internal links to the preferred destination. If a plugin injects another canonical, correct the responsible configuration. If the pages are genuinely different, improve their distinct content instead of escalating competing tags. After changes, keep the inspection result separate from the intended configuration; neither a local parser nor a sitemap edit proves re-evaluation has happened.
For broader search work, see SEO services. Template and response changes belong in the web development brief. Get started with a redacted URL-family record and the particular conflict you need investigated.
By Spout Team. AI-assisted drafting by Codex using the linked primary documentation.