How to Fix a Missing Canonical Tag on Your Pages

Your audit found pages whose HTML has no <link rel="canonical"> tag, so search engines have to guess which URL is the official version. By the end of this guide, every indexable page will declare its own absolute, preferred URL in the <head>, and you will have confirmed it in the page source and in Google Search Console.

By Updated ⏱ 20–45 minutes🎯 Beginner● High impactOn-Page
Illustration: Canonical tag present fix guide
ON-PAGE · FIX GUIDE Canonical tag present IMPACTEFFORT TIME20–45 minutes LEVELBeginner

Why it matters

utm_source=, with or without a trailing slash, or through filtered collection paths. Without a canonical tag, Google picks one of these itself. That can split link signals across duplicates, show an ugly parameter URL in results, or leave the wrong version indexed.

AI search tools and crawlers that cite your pages also rely on the canonical to choose which URL to attribute. A self-referencing canonical removes the guesswork for almost no effort.

✕BeforeView source onhttps://example.com/blog/pricing-guide?utm_source=newslettershows no <link rel="canonical">✓AfterThe same page's <head> contains <linkrel="canonical"href="https://example.com/blog/pricing-guide">.

What you need

Access to your theme, template files or CMS SEO settings
Your preferred domain format (https, www or non-www, trailing slash or not)
A crawler such as Screaming Frog SEO Spider, or the audit report listing affected URLs
Google Search Console access for the property (for verification)

Step-by-step fix

1

List the pages missing a canonical

Start from the URLs flagged in your audit report. The check counts every crawled page that lacks a canonical tag, so the goal is full coverage, not just your homepage. To see the pattern, crawl the site with Screaming Frog (Canonicals tab > filter Missing) and group the results by template: blog posts, product pages, category pages, tag archives, landing pages.

Usually one or two templates cause most of the gaps.

Pro tip: If only certain templates are missing the tag, such as tag archives or search pages, fix the template rather than editing pages one by one.
2

Decide the exact canonical URL format

Choose one format and use it everywhere:

  • Absolute URL, including protocol and host: https://example.com/page, not /page
  • Your preferred host: www or non-www, whichever your redirects point to
  • Consistent trailing slash that matches your internal links
  • No tracking or session parameters: remove utm_*, gclid, fbclid and sessionid

Keep parameters that genuinely change the content, such as ?page=2 on pagination.

Pro tip: Make sure the canonical URL returns 200 directly. If it redirects or returns 404, Google ignores the hint.
3

Add the tag to the <head> of each page template

For hand-coded or server-rendered sites, put the tag in the shared header or layout file so every page outputs it. Build the href from the current request path, without the query string, and prepend your canonical origin. Output only one canonical per page, and place it inside <head>.

Google ignores canonical tags that appear in <body>.

php
<!-- Inside <head> of every page template -->
<link rel="canonical" href="https://example.com/current-page-path">

<?php // PHP example: strip query string, force preferred origin
$path = strtok($_SERVER['REQUEST_URI'], '?');
echo '<link rel="canonical" href="https://example.com' . htmlspecialchars($path) . '">';
?>
Pro tip: Render the tag in the server HTML. Canonicals injected later by JavaScript or Google Tag Manager are less reliable, and many crawlers never see them.
4

Enable it in your CMS or theme

Most CMSs can output a self-referencing canonical automatically:

  • WordPress: Core already outputs a canonical on single posts and pages. Installing Yoast SEO or Rank Math extends it to archives, categories and the homepage.
  • Shopify: Open Online Store > Themes > … > Edit code > layout/theme.liquid and confirm the line below is inside <head>.

If a page builder or a custom theme removed the hook, add the tag back.

liquid
<link rel="canonical" href="{{ canonical_url }}">
Pro tip: In WordPress, check that the theme's header.php still calls wp_head(). If it doesn't, neither core nor the SEO plugins can output the tag.
5

Set canonicals in JavaScript frameworks

js App Router, set metadataBase once in the root layout. tsx, or in generateMetadata for dynamic routes. That way each URL resolves to its own path.

A relative canonical defined only in the root layout can resolve to the homepage for every route, which is worse than having no tag.

javascript
// app/layout.tsx
export const metadata = { metadataBase: new URL('https://example.com') };

// app/blog/[slug]/page.tsx
export async function generateMetadata({ params }) {
  const { slug } = await params;
  return { alternates: { canonical: `/blog/${slug}` } };
}
Pro tip: In Nuxt, use useHead({ link: [{ rel: 'canonical', href }] }). In Astro, add the tag in your base layout using Astro.url.pathname.
6

Handle duplicates and non-HTML files deliberately

Self-referencing is the default. Point to a different URL only when a page truly duplicates another, such as a print version or a product reached through a collection path. page=2) should canonicalize to themselves, not to page 1.

For PDFs and other non-HTML files, send the canonical as an HTTP Link header.

nginx
# Nginx: canonical header for a PDF
location = /docs/price-list.pdf {
  add_header Link '<https://example.com/docs/price-list.pdf>; rel="canonical"';
}
Pro tip: Don't combine noindex with a canonical pointing elsewhere on the same page. The two send conflicting signals.
7

Verify the tag on live pages

Clear any page cache or CDN cache first. Then check one URL from each template:

  • View the page source and confirm there is exactly one canonical.
  • Request a parameter version of the URL and confirm the canonical drops the parameter.
  • Recrawl the site and confirm the Missing filter is empty.
  • Re-run the audit.
text
curl -s "https://example.com/blog/pricing-guide?utm_source=test" | grep -i 'rel="canonical"'
Pro tip: In Search Console, open URL Inspection for a fixed page and click Test Live URL. The **User-declared canonical** field should show your URL.

Platform-specific notes

WordPress

Core adds canonicals only to singular posts and pages. Yoast SEO or Rank Math covers archives and the homepage. To override a single post's canonical, use the Yoast sidebar (Advanced > Canonical URL) or Rank Math (Advanced tab > Canonical URL). Only one SEO plugin should be active, or you may get duplicate tags.

Shopify

Dawn and most Online Store 2.0 themes include {{ canonical_url }} in layout/theme.liquid. Older or heavily customized themes sometimes lose it. canonical_url already strips collection paths (it points /collections/x/products/y to /products/y) and removes most query parameters.

Wix

Wix adds self-referencing canonicals automatically. To override one, go to Pages & Menu > page ⋯ > SEO basics > Advanced SEO > Canonical tag. If the audit flags pages, check for custom canonicals that are blank, or code added through Settings > Custom Code.

Webflow

Go to Site settings > SEO > Global canonical tag URL and enter https://example.com, then publish. Webflow will then output a self-referencing canonical on every page. You can override individual pages in Page settings > SEO settings > Canonical URL, or set them for CMS templates.

Cloudflare / CDN

Purge the cache after deploying, or crawlers will keep receiving the old HTML without the tag. Also check that HTML minification or Workers scripts don't strip <link> tags from the <head>.

Check that it worked

✅ How to verify

  • View the page source (Ctrl+U or Cmd+Option+U) on one URL per template and confirm exactly one <link rel="canonical"> appears inside <head>, with an absolute https URL.
  • Run curl -s URL | grep -i canonical against a URL with ?utm_source=test added and confirm the canonical omits the parameter.
  • Use Google Search Console URL Inspection > Test Live URL and check that User-declared canonical matches your intended URL.
  • Recrawl with Screaming Frog (Canonicals > Missing should show 0) and re-run the audit.

⚠️ Common mistakes

  • Hardcoding the homepage URL as the canonical in a shared header, so every page tells Google it is a duplicate of the homepage.
  • Using relative or protocol-less URLs (href="/page" or "//example.com/page"), or pointing at http:// or the non-preferred www host.
  • Outputting two canonical tags, one from the theme and one from an SEO plugin. Google may ignore both.
  • Copying query strings such as utm_source or sessionid into the canonical href instead of stripping them.

Is this still an issue on your site? Run a free audit — ZORO checks this and 294 other SEO, AI-visibility, accessibility and security signals, with fixes for your platform.

Check my site free

FAQ

Does every page need a canonical tag even if it has no duplicates?

Yes, for indexable pages. Parameters, tracking links and host variants create duplicates you may not know about. A self-referencing canonical makes sure Google consolidates them onto the URL you choose.

Is a self-referencing canonical tag bad for SEO?

No. Google recommends it as a best practice. It simply confirms that the current URL is the preferred version.

Can the canonical URL be relative?

Google accepts relative canonicals, but absolute URLs are safer. Relative paths can resolve incorrectly on staging hosts, http versions or mirrored domains.

Why does Google choose a different canonical than mine?

The canonical tag is a hint, not a directive. Google may override it if your internal links, sitemap or redirects point to a different version, or if the content differs. Align all those signals with the URL in your canonical tag.