Canonical URLs and Duplicate Content
The same page reachable at seven URLs is seven competing pages to a search engine. One line of markup consolidates them.
- Concept
- How duplicates appear
- The canonical link
- Rules
- Canonical or redirect?
- The cases that come up
- Campaign parameters
- Pagination
- Filtered and sorted listings
- Syndicated content
- Language versions
- Preventing duplicates in the first place
- Pick one host and redirect
- Pick one trailing slash convention and redirect
- Keep URLs lower case
- Do not serve index.html directly
- Diagnosing it
- Important rules
- Common mistakes
- Best practices
- Practice
-
HTML Basics
- What is HTML: The Structure Layer of Every Web Page
- HTML Document Structure: DOCTYPE, html, head and body
- Elements, Tags and Attributes: The Vocabulary of HTML
- HTML Comments: Notes That Ship With Your Code
- Block Level and Inline Elements
- Writing and Running Your First HTML Page
- How a Browser Turns Markup Into a Page
- Text and Formatting
- Links and Navigation
- Images and Media
- Lists
- Tables
-
Forms
- Form Structure: form, action and method
- Input Types: Text, Email, Number, Date and the Rest
- Labels: The Most Important Element in a Form
- Checkboxes, Radio Buttons and Grouping
- select, option, optgroup and datalist
- textarea, File Uploads and Hidden Fields
- Buttons: submit, reset and button
- Built In Form Validation
- GET or POST: What Happens When a Form Is Submitted
- Semantic HTML
- HTML5 Features
- Head and Metadata
- HTML with CSS
- HTML with JavaScript
- Accessibility
-
HTML SEO
- How Google Works: Crawling, Indexing and Ranking
- SEO Friendly HTML Structure
- Titles and Descriptions That Earn Clicks
- Headings and Content Structure for Search
- Internal Linking and Anchor Text
- robots.txt and XML Sitemaps
- Canonical URLs and Duplicate Content
- Structured Data and JSON-LD
- Image SEO
- Core Web Vitals and Mobile Friendliness
- DevTools and Debugging
- Editor Productivity
- HTML Best Practices
- HTML Projects
- Advanced Projects
- Practice and Exams
Concept
Search engines treat a URL as a page. If the same content is reachable at several URLs, that is several pages with identical content - and the signals that would make one page rank are split across all of them.
This happens far more often than people expect, and almost always by accident.
How duplicates appear
https://example.edu/courses/design
https://example.edu/courses/design/
http://example.edu/courses/design
https://www.example.edu/courses/design
https://example.edu/courses/design?utm_source=newsletter
https://example.edu/courses/design?ref=facebook
https://example.edu/Courses/Design
https://example.edu/courses/design/index.htmlEight URLs, one page. Add campaign parameters, session ids, sort orders and pagination and a medium sized shop can generate thousands.
The canonical link
<link rel="canonical" href="https://example.edu/courses/design">It says: of all the URLs showing this content, index this one. Every duplicate carries the same tag, pointing at the same target, and the signals consolidate onto that one URL.
Rules
- Absolute URL. A relative one is a common and silent failure.
- Self referencing. The canonical page should point at itself. It removes ambiguity and handles parameters added later.
- One per page. Two canonical tags are treated as none.
- A hint, not a command. Google may ignore a canonical that points at clearly different content.
- Consistent with everything else - the sitemap, internal links and redirects should all agree.
<!-- fails silently -->
<link rel="canonical" href="/courses/design">
<!-- correct -->
<link rel="canonical" href="https://example.edu/courses/design">Canonical or redirect?
| Situation | Use |
|---|---|
| The URL has changed for good | 301 redirect |
| The old URL should stop working | 301 redirect |
| Both URLs must keep working | Canonical |
| Tracking parameters on a shared URL | Canonical |
| A printer friendly version | Canonical |
| Content syndicated on another domain | Cross domain canonical |
A redirect is stronger: it removes the duplicate entirely. Use it whenever the alternative URL does not need to keep working.
The cases that come up
Campaign parameters
<!-- on /courses/design?utm_source=newsletter -->
<link rel="canonical" href="https://example.edu/courses/design">Tracking parameters must not create index entries. A self referencing canonical on the clean URL handles it automatically.
Pagination
<!-- on page 2, canonical points at page 2, not page 1 -->
<link rel="canonical" href="https://example.edu/journal?page=2">Pointing every paginated page at page one is a common error. Pages two onwards then never get indexed, and the articles listed only on them are harder to discover. Each page is its own page.
Filtered and sorted listings
<!-- on /products?colour=brass&sort=price -->
<link rel="canonical" href="https://example.edu/products">Filter combinations can produce an effectively unlimited number of URLs. Canonicalise them to the unfiltered listing, and consider blocking the parameter paths in robots.txt as well to save crawl budget.
Syndicated content
<!-- on the republished copy -->
<link rel="canonical" href="https://original.example/articles/bus-timetable">The correct way to publish an article in two places without competing with yourself.
Language versions
<link rel="canonical" href="https://example.edu/hi/courses/design">
<link rel="alternate" hreflang="en" href="https://example.edu/courses/design">
<link rel="alternate" hreflang="hi" href="https://example.edu/hi/courses/design">
<link rel="alternate" hreflang="x-default" href="https://example.edu/courses/design">Different languages are not duplicates. Each version canonicalises to itself, and hreflang links them. The set must be reciprocal: every version lists every other version including itself, or the whole group is ignored.
Preventing duplicates in the first place
Pick one host and redirect
http://example.edu/* -> https://example.edu/*
https://www.example.edu/* -> https://example.edu/*Pick one trailing slash convention and redirect
/courses/design/ -> /courses/designKeep URLs lower case
Most servers treat /Courses and /courses as different. Redirect uppercase variants.
Do not serve index.html directly
/about/index.html -> /about/Diagnosing it
In Search Console, URL Inspection reports the Google selected canonical alongside the one you declared. When they differ, Google has overruled you - usually because internal links, the sitemap or redirects point somewhere else.
The Pages report lists exclusion reasons including Duplicate without user selected canonical and Alternate page with proper canonical tag. The first is a problem; the second is the system working.
Important rules
- Canonical URLs must be absolute.
- Every page should have a self referencing canonical.
- One canonical per page.
- Redirects are stronger than canonicals.
- Language versions are not duplicates.
hreflangsets must be reciprocal.- Canonical, sitemap and internal links must agree.
Common mistakes
- Relative canonical URLs.
- Every page canonicalising to the home page, which deindexes the site.
- Paginated pages all pointing at page one.
- Canonical pointing at a redirecting or non existent URL.
- Two canonical tags, one from a template and one from a plugin.
- No redirect between the www and non www forms.
- Canonicalising language versions to each other.
Best practices
- Self referencing absolute canonical on every page, generated by the template.
- Redirect to one host form and one trailing slash convention at the server.
- Keep sitemap URLs identical to the canonical URLs.
- Link internally to canonical URLs, never to redirecting ones.
- Give each paginated page its own canonical.
- Check the Google selected canonical after launch.
Practice
- List every URL form that reaches your home page. How many are there?
- Add a self referencing canonical to a template and verify it renders as an absolute URL.
- Explain why canonicalising page two of a listing to page one is harmful.
- Use URL Inspection to compare your declared canonical with the one Google selected.