The short version
- A canonical tag is a line in the
<head>that names the preferred URL for a piece of content. - It is a strong hint, not a command. Google follows it when your redirects, sitemap and internal links agree with it.
- Put a self-referencing canonical on every indexable page, use absolute URLs, and point true duplicates at the main version.
- Use a 301 when the old URL no longer needs to exist, and noindex when a page should not appear in search at all.
What is a canonical tag?
A canonical tag is an HTML link element with the attribute rel="canonical". It sits in the <head> of a page and tells search engines which URL is the main, preferred version of that content. The word comes from "canon": the authoritative original that copies are measured against.
<head>
<link rel="canonical" href="https://www.example.com/running-shoes">
</head>
The URL in the href is the canonical URL. Any page that carries this tag is saying: "If you find this content at several addresses, this is the one to index and show in results." Search engines call the overall process canonicalisation. Google groups pages whose main content is the same or nearly the same into a cluster, then picks one representative URL for the cluster. The other URLs become alternates or duplicates and are generally not shown.
The element has two required parts:
rel="canonical"declares the relationship. The samelinkelement is used for other relationships too, such asrel="stylesheet"orrel="alternate", so therelvalue is what makes it a canonical.hrefholds the preferred URL. Use the full absolute address, including protocol and host.
Bing, Yandex and other engines support the same tag, so one implementation covers every major search engine.
Why the same content ends up on many URLs
Very few duplicate pages are created on purpose. Most come from the way servers, CMSs and marketing tools build addresses. To a crawler, each of these is a separate URL:
| Source of duplication | Example variants |
|---|---|
| Protocol | http:// and https:// |
| Host name | www.example.com and example.com |
| Trailing slash | /shoes and /shoes/ |
| Letter case | /Shoes and /shoes (paths are case sensitive) |
| Default file names | /, /index.html, /index.php |
| Tracking parameters | ?utm_source=newsletter, ?gclid=, ?fbclid= |
| Session IDs | ?sid=8f2a91 appended by older platforms |
| Sorting and filtering | ?sort=price, ?colour=red&size=9 |
| Multiple category paths | /mens/shoes/trail-runner and /sale/trail-runner |
| Product variants | /trail-runner?variant=blue |
| Print or text-only versions | /guide/print |
| Separate mobile or AMP pages | m.example.com/page, /page/amp |
| Staging or development copies | staging.example.com left open to crawlers |
| Syndication and republishing | The same article on your blog, Medium and a partner site |
Some of these, like protocol and host, are best fixed with site-wide redirects. Others, like tracking parameters and filtered category pages, have to stay live because people and tools use them. That second group is where canonical tags do their real work.
Why canonical tags matter for SEO
Duplicate content does not trigger a penalty on its own. The problem is dilution and loss of control. A clear canonical gives you four practical benefits:
- You choose the URL people see. Without a declared preference, Google might show a long parameter URL or the HTTP version in results.
- Ranking signals are consolidated. Links pointing at duplicate addresses are credited to the canonical URL, rather than being split across five versions that each rank weaker.
- Reporting gets cleaner. Search Console and analytics data collect under one URL instead of being scattered across variants.
- Crawling is more efficient. Google crawls known duplicates less often over time, leaving more of its attention for new and updated pages. This matters most on large ecommerce and publishing sites.
Canonicals are not mandatory. If you declare nothing, Google still picks a canonical by itself. Declaring one simply means the choice is yours rather than a guess.
How Google chooses a canonical URL
Google does not read a canonical tag and obey it blindly. It looks at a set of signals, weighs them, and selects what it calls the Google-selected canonical. Your tag is the user-declared canonical. When the two match, everything is working. When they differ, at least one other signal is pulling in a different direction.
The signals Google weighs include:
- Redirects: a permanent redirect is a very strong sign that the target is preferred.
rel="canonical"in HTML or in an HTTP header: a strong signal.- Sitemap inclusion: a weak signal. Every URL listed in a sitemap is treated as a suggested canonical.
- Internal links: the URL your own site links to most consistently looks like the preferred one.
- HTTPS: Google prefers HTTPS over HTTP when both exist, unless the certificate is broken.
- hreflang clusters: URLs referenced in hreflang annotations are favoured as canonicals for their language.
- Content similarity: if the "duplicate" is clearly different from the declared canonical, the tag is likely to be ignored.
- URL quality: shorter, cleaner URLs tend to win over long parameter strings when other signals are mixed.
The lesson: signals stack. A canonical tag that points to URL A, while the sitemap lists URL B and the navigation links to URL C, sends three different messages. Make every signal name the same address.
Every way to declare a canonical URL
| Method | Strength | Best for | Watch out for |
|---|---|---|---|
| 301 or 308 redirect | Strong | Retiring a URL for good: HTTP to HTTPS, www to non-www, moved pages | Visitors can no longer reach the old URL |
<link rel="canonical"> in HTML | Strong | Duplicates that must stay accessible, such as parameter and filter URLs | Only works inside <head> of HTML pages |
Link: HTTP header | Strong | PDFs, documents and other non-HTML files | Do not send a different value from the HTML tag |
| XML sitemap | Weak | Supporting the other methods across a large site | List canonical URLs only, never the duplicates |
| Internal links | Supporting | Reinforcing the choice everywhere | Menus or breadcrumbs that link to a variant |
The HTTP header version looks like this. It is the only way to canonicalise a file that has no <head>, such as a PDF:
HTTP/1.1 200 OK
Content-Type: application/pdf
Link: <https://www.example.com/guides/sizing>; rel="canonical"
Pick one of the two rel="canonical" forms per URL. Using both is allowed, but if they ever disagree, Google may ignore both.
Self-referencing canonical tags
A self-referencing canonical is a tag that points to the page it sits on. It looks redundant, but it is one of the most useful defaults in technical SEO. Anyone can link to your page with ?ref=twitter on the end, with capital letters, or through an old host name. A self-referencing canonical on the clean URL tells search engines to fold all of those variants back into the right address automatically.
<!-- On https://www.example.com/blog/canonical-guide -->
<link rel="canonical" href="https://www.example.com/blog/canonical-guide">
Two rules make self-referencing canonicals work:
- Generate the canonical from the clean URL, not the requested URL. If your template simply echoes back whatever address was requested, the parameter version will declare itself canonical, which defeats the point.
- Match your real URL format exactly. If your site uses no trailing slash and HTTPS on the non-www host, the canonical should too.
Cross-domain canonicals and syndicated content
A canonical can point to a URL on a different domain. This is common when the same article is published in more than one place: a guest post you also keep on your own blog, a press release on a newswire, or a post cross-published to Medium or LinkedIn. The copy points its canonical at the original, so the original collects the credit.
<!-- On partner-site.com/republished-article -->
<link rel="canonical" href="https://www.your-site.com/original-article">
Two cautions. First, the partner has to add the tag, and many platforms do not let you control it. Second, Google has said that for syndicated news and articles it does not rely on the canonical alone, because the copies are often surrounded by different content. If being the ranking version really matters, ask the partner to add noindex to their copy, or to link clearly to the original.
Cross-domain canonicals are also used when a business runs the same content on two domains during a rebrand or consolidation, before the old domain is fully redirected.
Canonical tag vs 301 redirect vs noindex vs robots.txt
These four tools are often confused because they all affect what appears in search. They answer different questions:
| Tool | Can visitors still use the URL? | Indexed? | Consolidates signals? | Use it when |
|---|---|---|---|---|
| rel=canonical | Yes | Usually the canonical only | Yes, when accepted | The duplicate has to stay live (filters, tracking links, variants) |
| 301 redirect | No, they are forwarded | The target only | Yes | The page has moved or been merged permanently |
| noindex | Yes | No | No | The page has no search value: internal search, thank-you pages, logins |
| robots.txt disallow | Yes | Can still be indexed from links | No | You need to save crawl resources on huge URL spaces; never for canonicalisation |
A quick way to decide:
- Does anyone still need the old URL? If no, redirect it with a 301.
- Is it a true duplicate of another page? If yes, keep it live and add a canonical pointing at the main version.
- Is it a unique page that simply should not be in search? Use noindex.
Do not combine noindex and a canonical to another URL on the same page. One says "drop this page" and the other says "merge this page into that one". Google has also said that robots.txt should not be used to choose canonicals, because a blocked page cannot be crawled, so its canonical tag is never read.
How to add canonical tags on any platform
On most modern platforms the canonical is already generated for you. Your job is usually to check what is being output, then override it where the default is wrong.
Plain HTML
Add the tag inside <head>, before any scripts that might fail. Keep it absolute, and keep exactly one per page.
<link rel="canonical" href="https://www.example.com/services/web-design">
PHP and other server-side templates
Build the canonical from a known base URL and the clean path, stripping query strings so every variant outputs the same value:
<?php
$base = 'https://www.example.com';
$path = strtolower(rtrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'));
$canonical = $base . ($path === '' ? '' : $path);
?>
<link rel="canonical" href="<?= htmlspecialchars($canonical) ?>">
If certain parameters do change the content (for example ?page=2), keep those and drop only the ones that do not.
HTTP header for PDFs (Apache and Nginx)
# Apache (.htaccess or vhost), needs mod_headers
<Files "sizing-guide.pdf">
Header add Link "<https://www.example.com/guides/sizing>; rel=\"canonical\""
</Files>
# Nginx
location = /files/sizing-guide.pdf {
add_header Link '<https://www.example.com/guides/sizing>; rel="canonical"';
}
WordPress
WordPress core outputs a self-referencing canonical on single posts and pages. SEO plugins extend it to archives and taxonomies and let you override it per page.
- Yoast SEO: edit the post, open the Yoast panel, go to Advanced, and enter the full address in Canonical URL. Yoast leaves the canonical out on pages set to noindex.
- Rank Math: edit the post, open the Rank Math panel, choose the Advanced tab, and fill in Canonical URL.
- All in One SEO: in the AIOSEO settings box, open Advanced and set Canonical URL.
- In code: filter the core value with
get_canonical_url, or the plugin's own filter if a plugin is active.
// functions.php: point one post at an external original
add_filter( 'get_canonical_url', function ( $url, $post ) {
if ( 123 === $post->ID ) {
return 'https://partner-site.com/original-article';
}
return $url;
}, 10, 2 );
// Same idea when Yoast is active
add_filter( 'wpseo_canonical', function ( $url ) {
return is_singular() && get_the_ID() === 123
? 'https://partner-site.com/original-article'
: $url;
} );
Hand-written filters are fine for a handful of exceptions. For hundreds of pages, use the plugin fields or a rule in your theme.
Shopify
Shopify adds canonicals automatically through the theme. Check that theme.liquid contains:
<link rel="canonical" href="{{ canonical_url }}">
Products reached through a collection, such as /collections/sale/products/trail-runner, canonicalise to /products/trail-runner. A common improvement is to change collection grids so they link straight to the /products/ URL, which aligns internal links with the canonical.
HubSpot
HubSpot outputs a self-referencing canonical by default. To override it, open the page or post editor, go to Settings, then Advanced options, and enter the canonical URL. Domain-level settings control whether canonicals are added automatically across the portal.
Wix, Squarespace and Webflow
- Wix: self-referencing canonicals are automatic. Custom values are set per page under SEO basics, then Advanced SEO, then Additional tags.
- Squarespace: canonicals are generated automatically and are not editable per page. Control duplicates through clean internal links and by removing unused pages.
- Webflow: set a global canonical base URL in Site settings, then SEO. Webflow then outputs a self-referencing canonical on every page. Collection pages can override it with a custom code tag.
React, Next.js and other JavaScript sites
Google can render JavaScript, but canonicals are safest in the initial HTML. If the server sends one canonical and JavaScript later rewrites it, Google may use either. In Next.js, declare it through the metadata API so it is server-rendered:
// app/blog/[slug]/page.tsx
export async function generateMetadata({ params }) {
return {
alternates: { canonical: `https://www.example.com/blog/${params.slug}` },
};
}
In single-page apps that only render on the client, use pre-rendering or server-side rendering for any page you want indexed, and do not inject the canonical with JavaScript alone.
Special cases
Pagination
Page 2 of a category is not a duplicate of page 1: it lists different items. Give each page in a series its own self-referencing canonical. Canonicalising every page to page 1 hides the products and articles further down the series. A "view all" page is the one exception: if it exists and loads quickly, the component pages can canonicalise to it.
Faceted navigation and filters
Filters can create millions of URL combinations. Canonicalise low-value combinations (sort orders, view modes, multiple stacked filters) to the unfiltered category. If a particular filter has real search demand, such as "red running shoes", give it a clean, crawlable URL of its own with a self-referencing canonical and unique copy.
Product variants
Colour and size variants that share one description usually canonicalise to the main product URL. If a variant has its own demand and its own content, it can stand alone as a separate canonical page.
International and multilingual sites
Translations are not duplicates. Each language version gets a self-referencing canonical, and hreflang annotations link the versions together. Never canonicalise the French page to the English one: that tells Google to drop the French page. The one gray area is same-language regional pages (for example en-AU and en-GB) with nearly identical text, where Google may cluster them anyway. hreflang still helps it show the right regional URL.
Separate mobile URLs and AMP
On a separate m-dot setup, the mobile page canonicalises to the desktop URL and the desktop page carries rel="alternate" pointing to the mobile one. AMP pages canonicalise to the regular page, and the regular page links to AMP with rel="amphtml". Most sites today are responsive, which removes the issue entirely.
Staging and development sites
Absolute canonicals pointing to the live domain protect you if a staging copy is accidentally crawled. Still, password-protect staging rather than relying on canonicals.
The most common canonical tag mistakes
- Relative URLs.
href="/shoes"is technically supported, but it breaks when content is scraped, served on a staging host, or accessed over the wrong protocol. Always use absolute URLs. - More than one canonical tag. A theme and a plugin each adding one is common. With conflicting values, Google may ignore them all.
- The tag outside the head. A canonical in the
<body>is ignored. Broken HTML in the head, such as an unclosed tag or a stray<div>injected by a script, can close the head early and push the canonical out of it. - Every page canonicalised to the home page. Usually a template bug. It tells Google that every page is a copy of the home page.
- Canonical pointing to a redirect, 404 or noindex page. The target must return 200, be indexable and be the final URL.
- Canonical chains. A points to B and B points to C. Point every duplicate straight at the final canonical.
- Canonicalising pages that are not duplicates. Different products, different articles or paginated pages are not duplicates. Google will usually ignore the tag and you lose clarity.
- Mixed signals. The canonical says one URL, while the sitemap, internal links, hreflang or redirects say another.
- Blocking duplicates in robots.txt. Google cannot crawl the blocked URL, so it never sees the canonical and may still index the URL from links.
- Combining noindex with a cross-page canonical. Pick one instruction.
- Canonicalising translations to one language. Use hreflang with self-referencing canonicals instead.
- Echoing the requested URL. A template that prints the current address including parameters makes every variant its own canonical.
- Protocol or host mismatch. A canonical that says
http://on an HTTPS site, orwwwon a non-www site, contradicts your redirects.
How to audit your canonical tags
Check canonicals at three levels: one page, the whole site, and how Google sees them.
1. Check a single page
View the page source and search for canonical. Confirm there is exactly one tag, it sits in the head, and its URL is absolute and correct. Check the raw HTML as well as the rendered DOM, because scripts can change it. From a terminal:
# Canonical in the HTML
curl -s https://www.example.com/page | grep -io '<link[^>]*canonical[^>]*>'
# Canonical in the HTTP header (PDFs and other files)
curl -sI https://www.example.com/files/guide.pdf | grep -i '^link:'
2. Crawl the whole site
Run a site crawler and filter for these issues:
- Indexable pages with no canonical
- Canonicals pointing to 3xx, 4xx or 5xx URLs
- Canonicals pointing to noindex or robots-blocked pages
- Pages with more than one canonical, or HTML and header values that disagree
- Canonicalised URLs that still appear in the XML sitemap or in internal links
- Relative canonicals and protocol or host mismatches
3. Compare with Google
In Google Search Console, use the URL Inspection tool on important pages. It shows the user-declared canonical next to the Google-selected canonical. If they differ, look at what else points to Google's choice: internal links, the sitemap, redirects, or near-identical content. Then review the Page indexing report for the statuses below.
What the Search Console canonical statuses mean
| Status | What it means | What to do |
|---|---|---|
| Alternate page with proper canonical tag | This URL points to another canonical, and Google agreed | Nothing, if that was intended |
| Duplicate without user-selected canonical | Google found this URL is a duplicate and picked a canonical itself because none was declared | Add a canonical if Google's choice is wrong |
| Duplicate, Google chose different canonical than user | You declared one URL, Google picked another | Inspect both URLs, compare content, align sitemap, links and redirects |
| Page with redirect | The URL redirects, so it is not indexed | Nothing, if the redirect is intended. Remove it from the sitemap. |
"Alternate page" entries are not errors. A healthy site with tracking parameters or filters often has thousands of them. The status worth watching is "Google chose different canonical", especially on pages you want to rank.
Canonical tag checklist
- One preferred format for every URL: protocol, host, case and trailing slash
- Site-wide 301s enforce that format (HTTP to HTTPS, one host, one slash style)
- Every indexable page has exactly one self-referencing canonical
- All canonicals are absolute URLs in the
<head>of the initial HTML - Canonical targets return 200, are indexable and are not redirected
- True duplicates (parameters, filters, variants, print pages) point to the main URL
- Paginated and translated pages keep their own self-referencing canonicals
- PDFs that duplicate HTML pages send a
Linkheader canonical - The XML sitemap lists canonical URLs only
- Internal links, menus and breadcrumbs link to canonical URLs
- No page mixes noindex with a canonical to another URL
- No duplicates blocked in robots.txt
- URL Inspection shows Google agrees on your key pages
Frequently asked questions
Is a canonical tag a directive or a hint?
A hint. Google treats rel="canonical" as a strong signal and weighs it against redirects, sitemaps, internal links, HTTPS and how similar the pages really are. It usually follows the tag when every signal agrees.
Do canonical tags pass link equity?
When Google accepts the canonical, signals such as links pointing at the duplicate URLs are consolidated onto the canonical URL. That is one of the main reasons to use them.
Should every page have a self-referencing canonical tag?
Yes. A self-referencing canonical on every indexable page protects it when someone links to it with tracking parameters, a different case or an alternative host.
Can a canonical tag point to another domain?
Yes. Cross-domain canonicals are supported. For syndicated articles Google suggests the partner also keeps its copy out of the index with noindex, because the tag alone may not be enough.
Should page 2 of a paginated series canonicalise to page 1?
No. Page 2 lists different items, so it is not a duplicate. Each page in a series should carry a self-referencing canonical.
Can I use noindex and a canonical tag on the same page?
Avoid it. noindex says drop this page and canonical says merge this page into another one. The two instructions conflict, so choose the one that matches your intent.
Does a canonical tag stop Google from crawling the duplicate?
No. Google has to crawl the duplicate to read the tag. Non-canonical URLs are usually crawled less often over time, but they are still crawled. To cut crawling of huge parameter spaces, also reduce the internal links that create them.
How long does it take Google to honour a new canonical tag?
It happens when Google recrawls and reprocesses both URLs, which can take days for busy pages and weeks or months for rarely crawled ones. Requesting indexing in Search Console can speed up an individual URL.