Canonical Tag Generator — Create Canonical Link Tags

Generate canonical link tags to prevent duplicate content issues. Paste URL and copy the HTML tag.

About Canonical Tag Generator — Create Canonical Link Tags

Canonical Tag Generator creates the correct rel="canonical" HTML tag for any URL and explains exactly when and how to use it. Prevents duplicate content penalties caused by URL parameters, www vs non-www, HTTP/HTTPS differences, and pagination. Includes implementation examples for WordPress, Shopify, and Next.js.

How to Use

  1. 1Enter the canonical (authoritative) URL — the one you want Google to index and rank.
  2. 2Click "Generate Canonical Tag" to produce the correct HTML snippet.
  3. 3Copy the tag and paste it inside the <head> section of every duplicate version of that page.
  4. 4For self-referencing canonicals, paste the tag in the <head> of the page itself.

Features

  • Generates correct rel="canonical" syntax with one click — no memorization needed
  • Prevents duplicate content penalties from URL parameters, www/non-www, and HTTPS issues
  • Includes real-world implementation examples for WordPress, Shopify, Next.js, and more
  • Explains the difference between canonical tags and 301 redirects clearly
  • Browser-based — your URLs are never sent to a server
01

What is a Canonical Tag? A Plain English Guide

When the same content is accessible at multiple URLs, search engines face a dilemma: which version should they index and rank? Without clear guidance, they may split ranking signals across duplicates — or pick the wrong version. A canonical tag solves this with a single line of HTML.

The Problem: Duplicate URLs Are Everywhere

Modern websites accidentally create duplicate content constantly. Your homepage might be accessible at https://example.com, https://www.example.com, http://example.com, and https://example.com/?ref=twitter — four different URLs with identical content. A product page might appear in three category paths. Every filtered view of a catalog creates a new URL. Without canonical tags, Google sees each as a separate page competing against the others.

The Solution: One Line of HTML

A canonical tag in the <head> of each duplicate page points to the authoritative version: <link rel="canonical" href="https://example.com/your-page/">. This tells Google: "All these URLs have the same content. Please index and rank this one, and assign all ranking signals (backlinks, crawl budget, PageRank) to it." Google then consolidates the duplicate pages into a single strong signal for the preferred URL.

Self-Referencing Canonicals — The Best Practice

Even pages with no obvious duplicates should include a canonical tag pointing to themselves. This is called a self-referencing canonical. It protects your page if someone scrapes and republishes your content (the copied version will have a canonical pointing back to you), and it prevents tracking parameters like ?utm_source=newsletter from being treated as separate pages by search engines.

02

When to Use Canonical Tags vs. 301 Redirects

Both canonical tags and 301 redirects consolidate duplicate content signals, but they work differently and suit different situations. Choosing the wrong one is a common and costly SEO mistake.

Use a Canonical Tag When Both URLs Must Stay Live

If your content legitimately needs to be accessible at multiple URLs — for example, an article that lives in two different category paths, or a product page accessible through a filter and a direct URL — use a canonical tag. Both URLs remain accessible to users, but Google indexes only the preferred one. The canonical tag preserves user experience while cleaning up the SEO signal.

Use a 301 Redirect When a URL Should Permanently Change

If an old URL no longer needs to exist — for example, you changed your site structure or merged two pages — use a 301 redirect. The old URL forwards users and crawlers to the new one, and ranking signals transfer over time. 301 redirects are stronger signals than canonical tags because they are directives, not hints. Google will always follow a 301.

Common Canonical Tag Mistakes to Avoid

Pointing a canonical to a URL that itself redirects — the canonical URL should be the final destination. Using relative URLs instead of absolute URLs — always use the full URL including https://. Adding canonical tags on paginated pages pointing to page 1 — this was once recommended but is now outdated; use individual canonicals per page. Having conflicting canonicals across different versions of the same page — all versions should point to the exact same canonical URL.

03

How to Implement Canonical Tags on Any Platform

Once you have generated your canonical tag with this tool, the implementation method depends on your platform. The tag must always appear inside the <head> element of your HTML.

WordPress (Yoast SEO / Rank Math)

Both Yoast SEO and Rank Math auto-generate canonical tags based on your page URL. For custom canonicals: in Yoast, open the page editor → Yoast SEO meta box → Advanced tab → "Canonical URL" field. In Rank Math, go to the page → Rank Math SEO → Advanced → Canonical URL. For programmatic control, add canonical tags via wp_head() and the available filter hooks in your functions.php.

Next.js (App Router and Pages Router)

In Next.js 13+ App Router, add canonical metadata to your layout.tsx or page.tsx: export const metadata = { alternates: { canonical: 'https://example.com/your-page/' } }. For Pages Router, use next/head: import Head from 'next/head' and add <link rel="canonical" href="https://example.com/your-page/" /> inside <Head>. Dynamic pages should generate the canonical dynamically based on the current slug or URL.

Shopify and Static Sites

Shopify themes include canonical tags automatically via theme.liquid. To override for specific pages, conditionally output a custom canonical tag in theme.liquid. For static sites (Hugo, Astro, Eleventy, Jekyll), add the canonical tag in your base layout template. Most static site generators support frontmatter variables that can be passed to the layout for per-page canonical control — check your framework's documentation for the canonical metadata API.

FAQ

What is a canonical tag? (Plain English)
A canonical tag is one line of HTML you add to a page's <head> that tells search engines: "This URL is the real version of this page." When Google finds your content at multiple URLs — with and without www, with ?ref=twitter parameters, or at both HTTP and HTTPS — it uses the canonical tag to decide which one to index and pass ranking signals to. Without it, Google has to guess, and may split your ranking power across duplicates.
When do I need a canonical tag?
You need a canonical tag when the same or very similar content is accessible at more than one URL. Common causes: www vs non-www (example.com and www.example.com), HTTP vs HTTPS, trailing slash differences (/page vs /page/), URL parameters from tracking or filtering (?sort=price, ?ref=newsletter), and paginated content. Adding a self-referencing canonical to every page — even without obvious duplicates — is a recommended best practice.
What is the difference between a canonical tag and a 301 redirect?
A 301 redirect sends users and crawlers to a different URL — the old URL effectively disappears. A canonical tag keeps both URLs accessible but signals to search engines which one is "correct." Use a 301 redirect when you want to permanently retire a URL. Use a canonical tag when both URLs must remain live (for example, an article accessible via different category paths, or a page that appears in multiple filtered views).
Should I add a canonical tag even if I have no duplicate content?
Yes. A self-referencing canonical tag — one that points to the page itself — is a best practice for every page. It protects your content if someone scrapes and republishes it (the copied version will have a canonical pointing back to you), and it prevents tracking parameters like ?utm_source=newsletter from being treated as separate pages by search engines.
Does the canonical tag guarantee Google will use my preferred URL?
No. Google treats canonical tags as a strong hint, not a command. In most cases Google follows it. But if Google's signals strongly indicate a different URL is the better canonical — for example, if the "preferred" URL has far fewer backlinks — Google may override your choice. Check which URL Google selected using the URL Inspection tool in Google Search Console.
How do I add a canonical tag in WordPress?
Yoast SEO and Rank Math both generate canonical tags automatically based on your page URL. To set a custom canonical in Yoast, go to the page editor → Yoast SEO meta box → Advanced tab → "Canonical URL" field. In Rank Math, go to the page → Rank Math → Advanced → Canonical URL. You can also add canonical tags manually in your theme's header.php using wp_head().

Found a bug or something not working as expected?

Report a bug →