SEO Guide

How to Set Up Canonical Tags Correctly

Canonical tags prevent SEO value from being diluted across duplicate content. Learn the correct setup, best practices, and common mistakes to avoid.

6 min read2026-04-08

The canonical tag (rel="canonical") is an HTML element that tells search engines which URL is the preferred version among duplicate pages. It prevents SEO value from being diluted across duplicate content.

What Is a Canonical Tag?

A canonical tag (rel="canonical") is an HTML element placed in the <head> section that tells search engines which URL is the preferred (original) version when the same or similar content exists at multiple URLs.

Google began supporting canonical tags in 2009. Today, it is the standard method for resolving duplicate content issues. While canonical is a "hint" rather than a directive, when set correctly it serves as a very strong signal to search engines.

/* Canonical tag basic syntax */

<head>
  <link rel="canonical" href="https://example.com/page" />
</head>

Why Are Canonical Tags Necessary?

Websites often have the same content accessible at multiple URLs unintentionally — due to URL parameters, www variations, HTTP/HTTPS, trailing slashes, and more. Search engines may treat these as separate pages, splitting your SEO value across duplicates.

25–30%

Percentage of web content that has duplicates

Up to 50%

Crawl budget wasted on duplicate URLs

1

Canonical URL Google indexes per duplicate group

When You Need Canonical Tags

Canonical tags are especially important in the following scenarios. Check if any apply to your site and set up proper URL canonicalization.

CaseExampleSolution
www vs non-wwwexample.com and www.example.comCanonicalize to one version
HTTP vs HTTPShttp://... and https://...Set HTTPS URL as canonical
URL parameters?sort=price&page=1 (sorting/filtering)Set parameter-free URL as canonical
Print pages/article and /article/printSet the regular page as canonical
Tracking parameters?utm_source=twitter&utm_medium=socialSet the clean URL as canonical
Mobile/Desktop URLsm.example.com and example.comSet desktop URL as canonical (responsive preferred)

Best Practices

Add self-referencing canonicals to every page

Setting each page's own URL as canonical prevents value dilution from parameterized URLs and content scrapers.

Use absolute URLs

Always specify canonical URLs as absolute (e.g., "https://example.com/page"). Relative paths may not be processed correctly.

Specify HTTPS URLs

Always use the HTTPS version for canonical URLs. Specifying HTTP prevents proper migration signals to search engines.

Set only one canonical per page

Multiple canonical tags on the same page may cause search engines to ignore all of them. Always include exactly one.

Match sitemap URLs

Ensure the URLs in your sitemap match your canonical URLs. Mismatches send conflicting signals to search engines.

Common Mistakes to Avoid

Using relative URLs

Specifying canonical URLs with relative paths like "/page" may prevent search engines from correctly identifying the preferred URL. Always use absolute URLs starting with "https://".

Combining canonical with noindex

Canonical says "index this URL as the preferred version" while noindex says "don't index this page." These contradictory signals cause Google to ignore one of them.

Wrong pagination canonicals

Setting page 1 as the canonical for page 2, 3, etc. of a blog listing is incorrect. Each paginated page has unique content and should use a self-referencing canonical.

Canonical points to a redirecting URL

If the canonical URL redirects (301) to another URL, it sends confusing signals to search engines. Always specify the final destination URL as the canonical.

Setup by CMS / Framework

WordPress

In WordPress, SEO plugins like RankMath or Yoast SEO let you set canonical URLs from the admin panel. For manual setup, add a hook in functions.php.

/* functions.php */
function add_canonical_tag() {
  if (is_singular()) {
    echo '<link rel="canonical" href="'
      . esc_url(get_permalink())
      . '" />';
  }
}
add_action('wp_head', 'add_canonical_tag');

/* RankMath / Yoast SEO */
/* SEO > General > Canonical URL */

Next.js

In Next.js App Router, use the metadata API with alternates.canonical. In Pages Router, add a <link> tag inside the <Head> component.

/* Next.js App Router (metadata) */
export const metadata: Metadata = {
  alternates: {
    canonical: "https://example.com/page",
  },
}

/* Next.js Pages Router (Head) */
import Head from "next/head"
<Head>
  <link
    rel="canonical"
    href="https://example.com/page"
  />
</Head>

Static HTML

For static HTML, add the <link rel="canonical"> tag directly in the <head> section. Since you need to set it manually on every page, managing it through templates is recommended.

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8" />
  <title>ページタイトル</title>
  <link
    rel="canonical"
    href="https://example.com/page"
  />
</head>
<body>...</body>
</html>

Check Your Site's Canonical Tag Setup

Enter a URL to instantly check your canonical tag settings for free. Also checks title, meta description, OGP, and structured data.

今井政和

Written by

今井政和

SEO Director / Frontend Developer

SEO Director with 20+ years of web industry experience. Creator of SEO_CHECK and the official WordPress plugin "ORECTIC SEO CHECK." Author of a book on web strategy inspired by Edo-era merchant principles.

@imai_director

FAQ

Apa itu canonical tag?
Canonical tag (rel="canonical") adalah elemen HTML yang memberi tahu mesin pencari URL mana yang merupakan versi yang diutamakan ketika konten yang sama atau serupa ada di beberapa URL. Ditulis sebagai <link rel="canonical" href="preferred-url"> di bagian <head>. Ini mencegah nilai SEO terpecah di halaman-halaman yang duplikat.
Apa perbedaan antara canonical tag dan redirect?
Canonical tag adalah "petunjuk" bagi mesin pencari — pengguna masih dapat melihat halaman asli. Redirect 301 secara fisik mengirim pengguna ke URL yang berbeda. Gunakan canonical ketika Anda ingin kedua halaman dapat diakses; gunakan redirect ketika ingin menggabungkan sepenuhnya. Perlu diingat bahwa Google memperlakukan canonical sebagai saran, bukan arahan.
Apakah canonical tag yang merujuk ke dirinya sendiri diperlukan?
Ya, itu direkomendasikan. Canonical yang merujuk ke diri sendiri (menunjuk ke URL halaman itu sendiri) membantu memperjelas URL yang diutamakan ketika halaman diakses dengan parameter pelacakan atau variasi URL. Google merekomendasikan pengaturan canonical self-referencing di semua halaman.
Apa saja kesalahan umum pada canonical tag?
Kesalahan umum meliputi penggunaan URL relatif (URL absolut wajib digunakan), menggabungkan canonical dengan noindex (sinyal yang bertentangan), menetapkan canonical semua halaman yang dipaginasi ke halaman 1 (setiap halaman memiliki konten unik), dan mengarahkan canonical ke URL yang melakukan redirect (selalu tunjuk ke URL tujuan akhir).
Bisakah canonical tag menunjuk ke domain yang berbeda?
Ya, canonical lintas domain memungkinkan Anda menentukan URL di domain yang berbeda sebagai versi yang diutamakan. Ini berguna ketika konten yang sama dipublikasikan di beberapa domain. Namun, Google mungkin tidak selalu menghormati canonical lintas domain — Google juga mempertimbangkan kesamaan konten dan otoritas situs.