Fixing Canonical Tag Errors: Missing or Broken Tags
A canonical tag is a single line in the head of a page that names the address search engines should treat as the main copy.
When the Meta Tag Analyzer reports a canonical problem, it usually means the tag is missing, written as a relative path, printed twice, placed outside the head, or pointing somewhere it should not, such as the home page or an http address. This guide is about the tag on the page: how to read it, what a correct one looks like on each type of page, and how to change it in the template that prints it.
What the canonical tag does, and what it does not
The canonical tag looks like this and belongs inside <head>:
<link rel="canonical" href="https://www.example.co.uk/garden-furniture/oak-bench/">
It tells search engines: if you find this content at more than one address, this is the address I would like you to index and show. It is useful because the same page is often reachable in several ways, for example with a tracking parameter added by an email campaign, with a sort order added by a filter, or through a second category path in a shop.
Three points about the tag are worth keeping in mind before changing anything:
- It is a hint, not a command. Google weighs the canonical alongside redirects, internal links, sitemaps and the content itself, and can pick a different address if the other signals point elsewhere. A correct tag makes its choice easy; a wrong tag makes it harder.
- It does not hide a page. A page with a canonical pointing elsewhere can still be crawled, and visitors can still reach it. If you want a page kept out of search entirely, that is a job for the robots meta tag, not the canonical.
- It only works in the head. Google only accepts
rel="canonical"when it appears in the<head>of the HTML, or in an HTTPLinkheader. A tag that ends up in the body, which happens when a stray element or broken markup closes the head early, is ignored.
This guide covers faults in the tag itself. When the tag is fine but the redirects, sitemap and internal links name a different address, the problem is a conflict between signals across the site, which has its own guide: canonical conflicts.
The canonical findings and what each one means
The analyzer reads the canonical from the HTML your server returns and compares it with the address it fetched. These are the faults it most often turns up, roughly in order of how much damage they can do.
| Finding | What you see in the source | Why it matters |
|---|---|---|
| Canonical points to the home page | Every page carries href="https://www.example.co.uk/" | You are telling search engines every page is a copy of the home page. They will usually ignore it, but some pages may be folded into the home page. |
| Canonical uses http or the wrong host | href="http://example.co.uk/about/"
on an https www site | Names an address that redirects, so the hint points at something that is not a final page. |
| Canonical is missing | No rel="canonical" in the head | Search engines choose for themselves between parameter and slash variants. Often fine, sometimes not. |
| More than one canonical | Two link rel="canonical" lines, often different | When the values disagree, Google may ignore both. |
| Relative canonical | href="/about/" or href="about" | Allowed,
but easy to break on staging copies and with a wrong <base> tag. Absolute is safer. |
| Canonical keeps parameters | href="...?utm_source=newsletter" | Each tracked link declares itself the main copy, so the duplicates you meant to merge stay separate. |
| Slash mismatch | Page is /contact/, canonical is /contact | Points at a redirect or at a second copy of the page. |
| Canonical outside the head | Tag appears after <body> in the source | Ignored by Google. |
| Empty or placeholder value | href="" or href="{{canonical}}" | A template variable failed to fill in. Treated as a broken hint. |
The right canonical for each type of page
For the great majority of pages the answer is simple: the canonical should be the page's own clean address. That is called a self-referencing canonical. The exceptions are the page types below, and they are where most wrong tags come from.
Ordinary pages, posts and products
Self-referencing, using the address you want in search: https, your chosen host (with or without www), your chosen trailing-slash style, lower case if your platform treats case as different, and no query string.
Paginated lists
Page 2 of a category should name page 2 as its canonical, not page 1. Pointing every page of a series
at the first page asks search engines to treat different lists of products or articles as duplicates,
and items that only appear on later pages can become harder to discover. Google stopped using rel="prev"
and rel="next" as an indexing signal some years ago, so there is no need to add them for
Google's sake, though they do no harm.
Filtered and sorted views
A category sorted by price shows the same products as the unsorted category, so its canonical should normally point to the unsorted address. A filter that produces a genuinely different page that people search for, such as a colour or material landing page with its own text, can be self-referencing instead. Decide this per filter, not per page.
Product variants
If each colour or size has its own address but the page content barely changes, point the variants at the main product. If each variant has distinct content, images and search demand, let each one reference itself. Mixing the two approaches in one shop is the usual source of confused reports.
Syndicated and republished articles
When a partner republishes your article with permission, ask them to add a canonical pointing to your original. That is a cross-domain canonical, and it is a legitimate use of the tag. Google has said it may not always honour it for syndicated news, so the original should also be linked from the copy.
Files that are not HTML
A PDF cannot carry a link element, but the server can send the same hint as a header:
Link: <https://www.example.co.uk/guides/care-guide/>; rel="canonical"
This is useful when a downloadable PDF duplicates an HTML page and you want the HTML version to appear in search.
Checking the canonical properly
The canonical has to be checked in the raw HTML, because that is the version crawlers read first. The element inspector in browser developer tools shows the page after scripts have run, so a tag added or rewritten by JavaScript will look correct there even when the source is wrong.
From the command line
curl -sL https://www.example.co.uk/garden-furniture/oak-bench/ | grep -io '<link[^>]*canonical[^>]*>'
If this prints two lines, you have two canonicals. If it prints nothing, check whether the tag is being added by a script, and check the response headers too:
curl -sI https://www.example.co.uk/brochure.pdf | grep -i '^link'
Where the tag sits
Open View Source and search for canonical. Note the line number, then search for </head>
and <body. If the canonical comes after either, it will not count. A common cause is
an element that is not allowed in the head, such as an <img> tracking pixel, a <div>
printed by a plugin, or text from an unclosed tag. Browsers and parsers that meet such an element close
the head at that point, so every tag after it lands in the body, including a canonical that is correctly
placed in your template.
Checking the target
Request the canonical address itself. It should return a 200 status with no redirect, carry the same
canonical pointing to itself, and not be blocked by a noindex. A canonical that points at
a redirect, a 404 or a noindexed page is a signal clash; the canonical
conflicts guide goes through clearing those up across redirects and sitemaps.
Search Console
URL Inspection shows two values: the user-declared canonical, which is what your tag says, and the Google-selected canonical, which is what Google decided. When they differ, the Pages report lists the address under "Duplicate, Google chose different canonical than user". That is not always a fault in your tag, but if the declared value is wrong, fix the tag first and then look at the other signals.
Where the canonical comes from on common platforms
Very few sites type canonicals by hand. The tag is written by a template or a plugin, so the fix happens there.
| Platform | What writes the tag | Where to change it |
|---|---|---|
| WordPress | WordPress core prints a canonical on single posts and pages; SEO plugins such as Yoast, Rank Math and SEOPress replace it with their own on every page type | The plugin's per-post field for an override; the plugin's settings or filters for rules. See meta tags in WordPress. |
| Shopify | The theme, normally {{ canonical_url }} in theme.liquid | The theme code. Check apps and custom snippets are not adding a second tag. |
| Next.js (App Router) | alternates.canonical in the Metadata API, resolved
against metadataBase | layout or page files, or generateMetadata
for dynamic routes. |
| Static sites and generators | A layout partial | Build the value from the site's base URL setting plus the page path, never from the request. |
| Custom PHP or other server code | Often built from the incoming request | Build from a fixed base URL and the normalised path, with the query string removed. |
The home page mistake
The most damaging template fault is a canonical hard-coded in a shared header file. Someone adds <link rel="canonical" href="https://www.example.co.uk/">
to fix the home page, forgetting that the same header is used by every page. Search the theme or layout
files for the literal string rel="canonical"; there should be exactly one place it is written,
and it should use a variable.
Building the value safely
In server code, never echo the requested address straight into the tag. That copies tracking parameters, mixed case and odd paths into the canonical, and on a badly configured server it can let anyone put their own host name into your tag. Use a configured base address and a cleaned path. A simple pattern in PHP:
<?php
$base = 'https://www.example.co.uk';
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$path = rtrim($path, '/') . '/';
?>
<link rel="canonical" href="<?= htmlspecialchars($base . $path) ?>">
Adjust the slash rule to your own site; the point is that the host and protocol are fixed and the query string is dropped.
Awkward cases
- Canonical set by JavaScript. Google can read a canonical added by script after rendering, but it recommends not using JavaScript to change a canonical that is already in the HTML, because the two versions can disagree. Put the correct value in the server-rendered HTML.
- Language versions. Each language or country version should reference itself. Pointing the French page at the English one tells search engines the French page is a duplicate, which cancels the hreflang annotations. See hreflang and canonical conflicts.
- AMP and print versions. An AMP page should name the regular page as canonical, and
the regular page should link to the AMP version with
rel="amphtml". Print-friendly copies should point to the normal page. - Staging copies. A staging site that uses relative canonicals will declare its own staging addresses. That is harmless only if staging is protected by a login. If it is public, absolute production canonicals at least point search engines back to the live site, but protection is the real fix.
- Mixed-case addresses. Some servers treat
/Oak-Bench/and/oak-bench/as different pages. Choose lower case, redirect the rest, and make the canonical match. - Encoded characters. Spaces and non-Latin characters in paths should be percent-encoded consistently, so the canonical is character-for-character the same as the address you link to.
The fix, step by step
Step 1
Read the canonical the server actually sends
Run the Meta Tag Analyzer on one page of each type: the home page, a normal content page,
a category, a product or article, and page two of a list. For each, also open View Source or use curl
and search for canonical. Write down the value, how many times it appears and whether it
sits before the closing head. Ignore the element inspector for this, because scripts may have changed
what it shows.
Step 2
Decide the correct target for each page type
Make a short table with one row per page type and the address its canonical should name. Most rows will say the page's own clean address. Mark the exceptions clearly: sorted views pointing to the unsorted list, thin variants pointing to the main product, syndicated copies pointing to the original, and print or AMP copies pointing to the normal page. Pagination pages reference themselves. This table becomes the rule you implement.
Step 3
Write the tag as one absolute https URL
Change the template so the canonical is built from a fixed base address, including https
and your chosen host, plus the cleaned path of the page. Strip query strings such as utm_source,
gclid and sort parameters, apply your trailing-slash rule and lower-case the path if your
server is case sensitive. Never build the value by echoing the requested address, and make sure the value
is HTML-escaped inside the attribute.
Step 4
Remove extra canonicals and move stray ones into the head
Search the theme, layout files, plugins and tag manager for anything
else printing rel="canonical" and switch off every source except one. On WordPress this
usually means letting the SEO plugin own the tag. Then look for elements that close the head early, such
as tracking pixels, plugin output or stray text before the canonical, and move them into the body so
the canonical sits inside a valid head.
Step 5
Correct the template rule, not single pages
Apply the fix where the tag is generated so every page of that type is corrected at once. Remove any hard-coded canonical from shared headers, which is how whole sites end up pointing at the home page. Keep per-page overrides for genuine exceptions only, and note them somewhere the team can see. Clear page and CDN caches afterwards, otherwise the analyzer and crawlers will keep seeing the old tag for a while.
Step 6
Check Google agrees with your choice
Re-run the analyzer on the same sample of pages and confirm there is exactly one canonical per page, in the head, with the expected absolute value. Request each canonical address and confirm it returns 200 with no redirect. In Search Console, inspect a few key pages and compare the user-declared canonical with the Google-selected one. Google will update its choice as it recrawls, which can take days or weeks.
Keeping canonicals correct
- One owner. Decide which layer prints the canonical, whether theme, plugin or framework, and document that the others must not.
- Test on deploy. A simple check in your build or monitoring that fetches a handful of pages and fails if there is not exactly one canonical, or if it does not start with your production base address, catches most regressions before search engines see them.
- Watch after theme or plugin changes. Theme updates, new SEO plugins and page builders are the usual reason a second tag appears. Re-run the analyzer on your sample pages after any such change.
- Keep the sitemap in step. Sitemaps should list only the addresses your canonicals name. When the two drift apart, the conflicts guide shows how to line up every signal.
- Review exceptions. Once a quarter, look at pages with a canonical pointing elsewhere and confirm each still makes sense. Variants and filters change as the product range does.
1. Does every page need a canonical tag?
It is not required, and search engines will choose a canonical for themselves when none is given. But a self-referencing canonical on every indexable page is cheap insurance. It stops tracking parameters, sort orders and slash variants being treated as separate pages, and it gives you a clear statement to compare against when Search Console reports that Google chose a different address. The important thing is that the tag is correct; a wrong canonical is worse than none.
2. Should the canonical be an absolute or relative URL?
Google accepts relative canonicals, but absolute ones are strongly preferred. A relative value such as a bare path depends on the address it is read from, so a copy of the page on a staging host or reached through a different protocol will declare that copy as canonical. A base tag in the head can also change how a relative value is resolved. Writing the full https address, including your chosen host, removes that ambiguity entirely and makes the tag easier to audit.
3. Why is my canonical being ignored by Google?
Usually because other signals disagree with it or the tag is not valid. Check that there is only one canonical, that it is inside the head rather than pushed into the body, that the target returns 200 without redirecting and is not noindexed, and that the two pages really are near-duplicates. Then check internal links and the sitemap point to the same address. Google treats the tag as a strong hint, but it will choose differently if most of your site says otherwise.
4. Should page 2 of a category point its canonical at page 1?
No. Each page in a paginated series shows different items, so it is not a duplicate of page 1, and pointing it there may make products or articles that only appear deeper in the list harder for search engines to find. Give each paginated page a canonical to itself, keep normal links between the pages so they can be crawled, and make sure page 1 of the series uses the clean category address rather than one with a page parameter added.
5. Is it a problem if the canonical points to a URL with a trailing slash and the page has none?
Yes, if the two addresses are different on your server. With and without a trailing slash are separate URLs, so a mismatch means the page names a different address, which is often a redirect. Choose one style, make the server redirect the other, and generate the canonical with the same rule. If both addresses currently load the same page without redirecting, fix the redirect as well, because the tag alone is only a hint.
6. Can I use a canonical tag instead of a 301 redirect?
Only when both addresses need to stay available to visitors. A canonical keeps the duplicate page usable, which suits tracking links, sorted views and printer-friendly copies. When a page has moved or been replaced and nobody needs the old address, a 301 redirect is the stronger and clearer signal, because it moves visitors and search engines alike. Using a canonical in place of a redirect for moved content leaves two pages live and relies on search engines accepting the hint.
7. What happens if a page has two different canonical tags?
When a page declares two different canonicals, Google has said it may ignore both and choose one itself, so your preference is lost. The usual causes are a theme and an SEO plugin each printing a tag, a hard-coded tag left in a header file, or a tag manager adding another. Find every source by searching the templates and plugin settings, keep the one that generates the correct value, and switch off the others rather than trying to make them match.
The Meta Tag Analyzer reads the head of your page and checks whether the canonical is correct, alongside the title, description, robots directives, viewport, Open Graph and X card tags.
Open Meta Tag Fixes โ