Technical SEO

Canonical Tags: What They Are, How to Implement Them, and 9 Mistakes

· · 24 min read · Updated 26 November 2026

A canonical tag is a <link rel="canonical"> element in a page’s <head> that names the URL search engines should treat as the main version of that content. Here is a canonical tag example you can copy:

<link rel="canonical" href="https://example.com/dresses/green-dress/" />

When the same page is reachable at several URLs, this one line tells Google which URL to index and show, and where to consolidate the signals from the others. This guide gives the exact syntax, nine canonical tag examples for the situations that cause most duplicates, how to add the tag in HTML step by step, how Next.js, Astro, WordPress and Shopify print it, and nine mistakes that quietly break it.

Key takeaways

  • A canonical tag is a strong hint, not a rule: Google ranks redirects and rel="canonical" as strong signals and sitemaps as a weak one, in order of strength.
  • Use exactly one canonical per page, in the <head>, with an absolute URL: add a self-referencing canonical to the preferred page itself.
  • Non-HTML files take a header, not a tag: send the canonical for a PDF as a Link HTTP response header.
  • Most canonical bugs are configuration bugs: a missing site URL, a canonical inherited from a root layout, or two plugins each printing one.
  • Duplicates also cost you in AI answers: Bing says AI systems cluster near-duplicate URLs and pick one page to represent the set.

What a canonical tag is

Canonicalisation is Google’s process of choosing one representative URL from a set of duplicate or near-duplicate pages. Google’s canonicalization docs define the canonical URL as “the URL of a page that Google chose as the most representative from a set of duplicate pages.” The canonical tag is how you state which URL you would prefer it to choose.

Several near-identical sheets of paper stacked together, with one sheet lifted out and highlighted as the chosen original.

The link relation itself is defined in RFC 6596, which describes it as specifying “the preferred IRI from resources with duplicative content.” In HTML it is a single <link> element with two attributes: rel="canonical" and an href holding the preferred URL.

Choosing the canonical matters because of what Google does next. The canonical is crawled most regularly, duplicates are crawled less often, and the canonical page is the main source Google uses to evaluate the content. Search results usually point to it.

Why it is a hint and not a directive

Google treats a declared canonical as one signal among several. Redirects and rel="canonical" annotations are strong signals, and sitemap inclusion is a weak one. The methods stack, so two signals that agree make it more likely your preferred URL wins. Two that disagree make it less likely.

When you need one

Google is candid that none of these methods is required: if you declare nothing, it picks the version it judges best. You declare a canonical when you care which URL wins. The usual sources of duplication are:

  • Parameters and tracking codes: ?gclid=, ?utm_source=, session IDs.
  • Sorting and filtering: the same category list at ?sort=price and ?colour=blue.
  • Protocol and host variants: HTTP and HTTPS, www and non-www.
  • Device and region variants: a separate mobile URL, or US and UK pages with the same English text.
  • Accidental copies: a demo version left open to crawlers.

Duplicate content of this kind is normal and not a spam problem. The cost is diluted signals, split reporting and crawl time spent on copies.

Canonical tag syntax

The rules for the HTML element are short. Each one comes from Google’s canonical documentation:

  1. It goes in the <head>. The element is only read there, so the <head> must be valid HTML up to that point.
  2. Use an absolute URL. Relative paths are supported but not recommended, because they can resolve against the wrong host, such as a crawlable staging site.
  3. One per page. Do not send one URL in the tag and another in a header or sitemap.
  4. No fragments. A URL with #section is not a valid canonical, because Google generally ignores fragments.
  5. Link internally to the canonical. Internal links that point at the preferred URL reinforce the tag.

This HTML canonical tag example shows the canonical code in context, in a minimal <head>:

<head>
  <meta charset="utf-8" />
  <title>Green dress | Example</title>
  <link rel="canonical" href="https://example.com/dresses/green-dress/" />
</head>

Put it early in the <head>. Google’s post on common rel=canonical mistakes recommends including it “as early as possible” to avoid parsing problems.

One syntax trap is worth knowing before you add hreflang or mobile annotations. A rel="canonical" element that carries hreflang, lang, media or type attributes is not used for canonicalization. Alternates always get their own <link rel="alternate"> element.

Canonical tag examples for 9 common situations

Each canonical tag example below shows the duplicate URL, the tag it should carry, and the one rule that decides it. Swap example.com for your own domain and the paths for your own URLs.

A grid of nine situations. Most point their duplicate URL at a preferred URL, while self-referencing and paginated pages point at themselves.

Where each of the nine situations should point its canonical.

1. Self-referencing canonical (every indexable page)

A self-referencing canonical is a canonical tag on the preferred page that points at that page’s own URL. Google recommends a self-referential canonical explicitly: “Do include a rel=“canonical” link on the canonical page itself.” This is the canonical tag example every indexable page should carry:

<!-- On https://example.com/pricing/ -->
<link rel="canonical" href="https://example.com/pricing/" />

The reason is that you do not control every URL that reaches your page. An ad click appends ?gclid=, a newsletter appends UTM parameters, and a scraper links to an odd variant. If the page always prints its own clean URL, every variant points back to the right place without you listing them.

2. URLs with tracking parameters

The same page, reached through a campaign link, carries the clean URL as its canonical. This canonical tag example covers utm_, gclid and session parameters alike:

<!-- Served at https://example.com/pricing/?utm_source=newsletter&utm_medium=email -->
<link rel="canonical" href="https://example.com/pricing/" />

The key detail is that the canonical is built from the clean path, not from the full requested URL. A template that echoes the request URL, query string included, gives each parameter variant a self-referencing canonical of its own. That is the opposite of what you want.

3. Sorted and filtered listing pages

Sorting does not change which products a page lists, so in this canonical tag example the sorted view points at the default view:

<!-- On https://example.com/dresses/?sort=price_asc -->
<link rel="canonical" href="https://example.com/dresses/" />

Filters need a decision rather than a rule. A filter that only narrows the same list (?colour=green with three items) is usually a duplicate and canonicalises to the category. A filtered view you want to rank as its own page, such as a “green dresses” landing page with its own copy, gets a clean URL and a self-referencing canonical instead.

4. One product in two categories

A product reachable under two category paths should name one of them, or a category-free path, as the canonical:

<!-- On https://example.com/sale/green-dress/ and https://example.com/dresses/green-dress/ -->
<link rel="canonical" href="https://example.com/dresses/green-dress/" />

Pick one path and link to it everywhere: in navigation, in the sitemap and in related-product blocks. The canonical and the links should name the same URL.

5. Campaign and landing page variants

Marketing teams often publish near-identical versions of a page for different audiences. Bing’s December 2025 guidance on duplicate content says to “use canonical tags on variations that do not represent a distinct search intent” and to keep separate pages only when the intent clearly changes.

<!-- On https://example.com/campaign/agencies/ (same offer, new headline) -->
<link rel="canonical" href="https://example.com/campaign/" />

A variant with different pricing, a different product or a different audience need is a separate page and canonicalises to itself.

6. Cross-domain canonical and syndicated content

A canonical can point to a URL on a different domain. Google announced cross-domain rel=canonical support on 15 December 2009, for cases such as moving a site from a server that cannot do redirects.

<!-- On https://old-domain.com/guides/canonical-tags/ -->
<link rel="canonical" href="https://example.com/guides/canonical-tags/" />

Map page to page. Pointing every old URL at the new home page “could result in problems,” in Google’s words, and a 301 redirect is the clearer instruction where you can set one.

Syndication is where the advice has changed. Google’s current troubleshooting guide says the canonical element “is not recommended for those who want to avoid duplication by syndication partners, because the pages are often very different.” Its recommended fix is for partners to block indexing of the syndicated copy. Bing, by contrast, still suggests asking partners for a canonical to your original. If you republish on Medium or a partner site, ask for both a canonical and a noindex where the agreement allows.

7. Language versions with hreflang

Canonical and hreflang answer different questions. The canonical picks one URL among duplicates. Hreflang maps language and region versions that should each stay indexed. Every language version carries a self-referencing canonical and the full hreflang set:

<!-- On https://example.com/de/preise/ -->
<link rel="canonical" href="https://example.com/de/preise/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/pricing/" />
<link rel="alternate" hreflang="de" href="https://example.com/de/preise/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/en/pricing/" />

The hreflang set is identical on every version, and each version must list itself as well as all others, with fully qualified URLs. The same page notes that translated pages count as duplicates only if the main content stays untranslated, so a German page canonicalised to the English one is a mistake.

Regional versions in the same language, such as US and UK English, are a different case. For those, Google says to use both canonicalization and hreflang. The conflicts and their fixes are covered in hreflang and canonical tags.

8. PDFs and other files: the HTTP header

PDFs, Word files and other non-HTML documents have no <head>, so the canonical travels in the response instead. Google supports a Link HTTP header with rel=canonical for documents it indexes, including PDF files, in web search results only. The format is:

Link: <https://example.com/guides/canonical-tags/>; rel="canonical"

A common use is a PDF version of an article that should defer to the HTML page. On nginx, attach the header in the location that serves the file:

location = /downloads/canonical-tags.pdf {
    add_header Link '<https://example.com/guides/canonical-tags/>; rel="canonical"';
}

On Apache with mod_headers enabled:

<Files "canonical-tags.pdf">
    Header set Link "<https://example.com/guides/canonical-tags/>; rel=\"canonical\""
</Files>

Check it with curl -I. This is the response from a small Node server set up to send that header for the original version of this article:

$ curl -sI http://localhost:8099/downloads/canonical-tags.pdf
HTTP/1.1 200 OK
Content-Type: application/pdf
Link: <https://example.com/guides/canonical-tags/>; rel="canonical"

The header also works on HTML pages, but pick one method. Using the header and the tag together is supported but more error prone, because the two can drift apart.

9. Paginated pages

Pages 2 onwards of a list show different items, so they are not duplicates of page 1. Google’s pagination guidance is direct: “Don’t use the first page of a paginated sequence as the canonical page.” In this canonical tag example, page 2 canonicalises to itself:

<!-- On https://example.com/blog/?page=2 -->
<link rel="canonical" href="https://example.com/blog/?page=2" />

This is the one common case where a query parameter belongs in the canonical. The full pattern is in pagination SEO.

How to add a canonical tag in HTML, step by step

Adding the tag is one line of HTML, exactly like the canonical tag example at the top of this page. Getting the right URL into that line is the real work. These five steps cover a hand-coded site; the framework sections below show where the same line lives in Next.js, Astro, WordPress and Shopify.

A numbered flow of five steps, from finding duplicate URLs and choosing the preferred one through to adding the tag and checking it.

The five steps for a hand-coded site.

  1. Find the duplicates. List every URL that serves the same main content: parameter variants, http/https and www versions, trailing-slash variants, print views and staging copies. Search Console’s Page Indexing report and a site crawl are the quickest sources.
  2. Choose the preferred URL. Pick the version you want in search results: HTTPS, your normal host, your normal trailing-slash style, and no tracking parameters.
  3. Add the element to the <head> of every version. Each duplicate gets <link rel="canonical" href="..."> pointing at the preferred URL, and the preferred page gets the same tag pointing at itself.
  4. Align the other signals. Google asks you to link to the canonical URL rather than a duplicate, and not to name different canonicals through different methods. List only canonical URLs in the sitemap, and redirect host and protocol variants where you can.
  5. Verify the output. Open the rendered page source, search for rel="canonical" and expect exactly one hit with an absolute https:// URL. Then check the URL in Search Console’s URL Inspection tool, covered at the end of this guide.

Step 3 is where hand-coded sites break. A canonical copied into a shared header include points every page at one URL, which is mistake 9 below. Build the href from each page’s own clean path instead of typing it.

Canonical tag vs 301 redirect vs sitemap

A canonical tag is one of three ways to declare a preferred URL. Google’s comparison of canonicalization methods sets out the trade-offs, summarised here:

Three columns compare a 301 redirect, a canonical tag or header, and sitemap inclusion. The redirect and the canonical are strong signals, the sitemap is weak, and only the redirect sends users away from the duplicate.

Three ways to declare a preferred URL, and how strong each signal is.

MethodSignal strengthUsers still see the duplicate?Best for
301 redirectStrongNo, they land on the canonicalRetired URLs, host and protocol variants, site moves
rel="canonical" tag or headerStrongYes, the duplicate keeps workingParameters, filters, campaign variants, PDFs
Sitemap inclusionWeakYesLarge sites, as a supporting signal only

Google notes that the sitemap is a less powerful signal than the canonical mapping, and that it still has to work out which duplicates each listed URL belongs to.

The rule I would apply: redirect when the duplicate has no reason to exist for users, canonicalise when it must stay reachable, and use the sitemap to agree with both. The redirect side, including chains and status codes, is covered in SEO redirects.

How frameworks and CMSs set canonical tags

On most sites a layout, a metadata API or a plugin writes the canonical from configuration, so the tag is only as correct as that config.

Next.js (App Router)

Next.js sets the canonical through the alternates.canonical field of the Metadata API. Set metadataBase once in the root layout so fields can use relative paths:

// app/layout.tsx
import type { Metadata } from 'next';

const SITE_URL = 'https://example.com';

export const metadata: Metadata = {
  metadataBase: new URL(SITE_URL),
};

Then set the canonical per route, usually in generateMetadata for dynamic pages:

// app/blog/[slug]/page.tsx
import type { Metadata } from 'next';

type Props = { params: Promise<{ slug: string }> };

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { slug } = await params;
  return {
    alternates: {
      canonical: `/blog/${slug}`,
      languages: {
        'en-GB': `/blog/${slug}`,
        'de-DE': `/de/blog/${slug}`,
      },
    },
  };
}

Next.js composes the relative path with metadataBase into an absolute URL. A relative path without metadataBase causes a build error, according to the same documentation. The alternates object also outputs hreflang links from languages.

The trap is inheritance. Metadata from nested segments is shallowly merged, and a nested object such as alternates is replaced by the last segment that defines it. If the root layout sets alternates: { canonical: '/' }, every route without its own alternates inherits a canonical pointing at the home page. A page that sets alternates.canonical without languages also drops the hreflang links a parent defined. Set alternates per route, completely. The wider set-up is in Next.js SEO.

Astro

In Astro the canonical usually lives in a shared layout that every page uses:

---
// src/layouts/BaseLayout.astro
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
---
<link rel="canonical" href={canonicalURL} />

Astro.site comes from the site option in astro.config.mjs. For the original version of this article, a one-page Astro project (Astro 5.18.2) was built three ways and the generated HTML read back:

ConfigWhat the build did
site: 'https://example.com', default build format<link rel="canonical" href="https://example.com/blog/post/">
No site setBuild failed with Invalid URL, because Astro.site was undefined
No site, canonical built from Astro.url instead<link rel="canonical" href="http://localhost:4321/blog/post/">
site set, build: { format: 'file' }<link rel="canonical" href="https://example.com/blog/post.html">

The failed build is the good outcome, because you notice it. The third row is the dangerous one: a “fix” that swaps Astro.site for Astro.url builds cleanly and ships a localhost canonical on every page. The Astro docs confirm why: if site is not configured, prerendered pages “will receive a localhost URL during builds as well.”

The fourth row shows the other thing to line up. The canonical follows your build.format and trailing-slash settings, so check they match the URLs you link to and list in the sitemap. More detail is in Astro SEO.

WordPress

WordPress core prints a canonical through rel_canonical(). Its rel_canonical() source code shows it only runs for singular queries (posts, pages, attachments), so core prints nothing on archives or the blog index. Since version 4.6 it takes its URL from wp_get_canonical_url(), which you can change with the get_canonical_url filter:

add_filter( 'get_canonical_url', function ( $canonical_url, $post ) {
    $override = get_post_meta( $post->ID, 'canonical_override', true );
    return $override ? $override : $canonical_url;
}, 10, 2 );

Most sites run an SEO plugin instead, which takes over canonical output. Yoast SEO, for example, adds a canonical to every post and page by default, and you override it in the editor sidebar under Advanced, in the Canonical URL field. Developers can use the wpseo_canonical filter. Yoast also does not print a canonical on pages marked noindex, so a missing tag there is expected behaviour.

The WordPress-specific risk is duplication: a theme that hard-codes a canonical in header.php, plus a plugin. Check the source for more than one tag after any theme or plugin change.

Shopify

Shopify themes print the canonical from the canonical_url Liquid object, a global object that returns “the canonical URL for the current page.” Dawn, Shopify’s reference theme, outputs it in layout/theme.liquid with one line:

<link rel="canonical" href="{{ canonical_url }}">

If your theme was built from Dawn or a similar starter, the tag is already there. Check that no app or snippet adds a second one, and edit the theme file only when you need a different rule for a template.

Client-side JavaScript

If the canonical has to come from JavaScript, Google’s rules are specific. Set it in the HTML if you can. If the HTML already has one, JavaScript must not change it to a different URL. If you cannot set it in the HTML, leave it out of the HTML entirely and inject it with JavaScript, and Google reads it when it renders the page. Render timing and the other JavaScript risks are in the JavaScript SEO guide.

Where the canonical stops and removal starts

A canonical keeps content in the index under a preferred URL. If the real goal is that a page should not appear in search at all, that is a different tool, and Google does not recommend using noindex to steer canonical selection within a site.

The decision rules for choosing between the two are in canonical vs noindex.

Canonical tags were designed for search engine indexes, but AI answer engines draw on the same indexes. Bing’s duplicate-content post says many LLMs rely on data grounded in the Bing index or other search indexes.

The same post says these systems group near-duplicate URLs into a single cluster and then choose one page to represent the set.

The practical consequence is the same as in classic search, with less room for error. If the differences between duplicates are small, the version chosen as the grounding source may be an outdated or unintended URL. Bing’s recommended fixes are the ones in this guide: clear canonical tags, consistent metadata, and IndexNow to tell participating engines quickly when you consolidate URLs or change canonicals.

Know the limit of that evidence. Bing describes its own systems and the engines that use its index. It does not show which URLs ChatGPT or other assistants cite, and a clean canonical does not guarantee a citation anywhere. What Bing’s tools do show is covered in Bing Webmaster Tools for AI search.

9 canonical tag mistakes

Each of these produces a tag that looks fine in the template and does nothing, or does damage, in practice.

1. A relative or scheme-less URL

href="example.com/page" has no scheme, so it is a relative path. Google’s 2013 mistakes post walks through this case: example.com/cupcake.html resolves to https://example.com/example.com/cupcake.html, and Google may ignore it. Always write the full https:// URL.

2. More than one canonical on the page

A theme prints one, an SEO plugin prints another, and a tag manager adds a third. When a page specifies more than one, all rel=canonical links will be ignored, per the same post. Search the rendered source for rel="canonical" and expect exactly one hit.

3. The canonical ends up outside the <head>

The source can be correct and the parsed page still wrong. If an <img> or <iframe> sits in the <head> above the canonical, Google assumes the head has ended and stops reading further elements. A canonical placed in the <body> is disregarded. Keep the canonical near the top of the <head> and check the rendered HTML, not only the template.

4. Paginated pages canonicalised to page 1

Page 2 and beyond list different items, so they are not duplicates of page 1. Give each page its own self-referencing canonical, as in example 9 above.

5. A canonical target that errors, redirects or is noindexed

The target has to exist and be indexable. Google’s checklist says to confirm the rel=canonical target exists and is not an error page, that it is not a soft 404, and that it carries no noindex robots tag. Point at the final URL, not one that redirects, so Google is not resolving two signals at once.

If a target serves a thin “not found” page with a success status code, fix that first: see soft 404 errors.

6. Signals that disagree with the tag

The canonical says /pricing/, the sitemap lists /pricing, and the navigation links to /pricing?ref=nav. Each of those is a vote for a different URL. Protocol counts too: an HTTPS page with a canonical pointing to HTTP is one of the conditions that stops Google preferring the HTTPS version.

7. JavaScript rewriting the canonical

A client-side router updates the title and, with it, the canonical, so the server HTML says one URL and the rendered page says another. Google’s JavaScript guidance says not to use JavaScript to change the canonical to anything other than the URL in the original HTML. Set it on the server, or only on the client, never both.

8. Blocking the duplicates you are canonicalising

Disallowing parameter URLs in robots.txt feels tidy, but Googlebot cannot read a canonical on a page it may not fetch. Google says not to use robots.txt for canonicalisation, since disallowed URLs can still be indexed without their content. Leave the duplicates crawlable so the tag is seen.

9. One canonical for many different pages

This is the template mistake. A layout hard-codes the home page as canonical, a copied template still points at the original site, or a category page canonicalises to the article it features that day. Google’s mistakes post describes this mistake: the category page drops out of results because you told Google the article is the preferred version of it. The Next.js inheritance trap above is the modern form of the same bug.

How to check which canonical Google chose

Your declared canonical and Google’s selected canonical are two different fields, and only one of them decides what is indexed.

  1. Read what you send. View the rendered HTML and count the canonical elements. For files, run curl -I and read the Link header.
  2. Read what Google chose. URL Inspection in Search Console shows the Google-selected canonical. If it differs from yours, ask whether Google’s choice is better for searchers before you fight it.
  3. Look for the technical cause. The usual suspects are CMS or plugin canonicals pointing at undesired URLs, misconfigured servers, missing hreflang and syndicated copies.
  4. Wait before you change it again. After a fix, Google may hold pages in a duplicate cluster for up to two weeks, and pages split out faster when their content is clearly different.

If Search Console lists a URL under “Duplicate without user-selected canonical”, Google found duplicates with no canonical declared; the fix is in duplicate without user-selected canonical. A URL under “Alternate page with proper canonical tag” usually means the tag is working; that status explained covers the rare case where it is not.

Automate the check across many URLs

Checking one page by hand is fine. Checking every template after each release is a job for a script. This one uses only the Python standard library. It reads a file of URLs, one per line, and flags pages that are not 200, pages with zero or several canonicals, relative canonicals, and canonical targets that do not return a clean 200:

import sys
from html.parser import HTMLParser
from urllib.error import HTTPError
from urllib.request import Request, urlopen


class CanonicalParser(HTMLParser):
    def __init__(self):
        super().__init__()
        self.canonicals = []

    def handle_starttag(self, tag, attrs):
        a = dict(attrs)
        rels = (a.get("rel") or "").lower().split()
        if tag == "link" and "canonical" in rels:
            self.canonicals.append(a.get("href") or "")


def fetch(url):
    req = Request(url, headers={"User-Agent": "canonical-check/1.0"})
    try:
        with urlopen(req, timeout=15) as r:
            return r.status, r.url, r.read().decode("utf-8", "replace")
    except HTTPError as e:
        return e.code, url, ""


def check(url):
    status, final_url, html = fetch(url)
    parser = CanonicalParser()
    parser.feed(html)
    tags = parser.canonicals
    problems = []
    if status != 200:
        problems.append(f"page returns {status}")
    if len(tags) != 1:
        problems.append(f"{len(tags)} canonical tags")
    for href in tags:
        if not href.startswith("https://"):
            problems.append(f"not an absolute https URL: {href}")
        elif href != url:
            t_status, t_final, _ = fetch(href)
            if t_status != 200 or t_final != href:
                problems.append(f"target returns {t_status}, ends at {t_final}")
    return tags, problems


if __name__ == "__main__":
    for line in open(sys.argv[1]):
        url = line.strip()
        if url:
            tags, problems = check(url)
            label = "OK  " if not problems else "FAIL"
            print(label, url, "->", tags, "; ".join(problems))

Run it as python3 check_canonicals.py urls.txt. It reads the server HTML only, so a canonical injected by JavaScript will show as missing; that is a useful warning in itself. It does not replace URL Inspection, because it shows what you send, not what Google chose. Scheduled after each deploy, it catches mistakes 1, 2, 5 and 9 before Google does. The same pattern, a fixed check on a schedule rather than a person opening pages, is how I would approach most repetitive SEO automation.

For a full crawl of a site, canonical checks sit in the indexation section of the technical SEO audit checklist. Canonicals get rewritten in bulk during replatforms and domain moves, which is when these mistakes arrive all at once, and the site migration checklist covers the pre-launch canonical inventory. If you would rather have the crawl-and-index layer set up and checked by someone who writes the code, that is part of GEO and technical SEO.

Frequently asked questions

What is an example of a canonical tag?

A canonical tag example is <link rel="canonical" href="https://example.com/dresses/green-dress/" />, placed in the <head> of every version of that page. The href holds the absolute URL you want indexed, and the preferred page carries the same tag pointing at itself.

How do I add a canonical tag in HTML?

Add a <link rel="canonical" href="..."> element inside the <head>, early, with the full https:// URL of the preferred page. Put it on every duplicate and on the preferred page itself, keep exactly one per page, and confirm it in the rendered source.

What is a canonical tag in SEO?

A canonical tag is an HTML <link rel="canonical"> element that names the preferred URL for content available at several URLs. Search engines use it to choose which URL to index and show, and to consolidate signals such as links from the duplicates. Google treats it as a strong hint, not a rule.

Should every page have a self-referencing canonical tag?

Yes, in most cases. A self-referencing canonical tag example is <link rel="canonical" href="https://example.com/pricing/" /> on /pricing/ itself. It protects the page from parameter variants such as ?gclid= or UTM tags that you do not control. Build it from the clean URL path, not from the full request URL with its query string.

Does Google always follow the canonical tag?

No. A canonical is one signal among several, alongside redirects, sitemaps, internal links and HTTPS. If those disagree with the tag, or the pages are not really duplicates, Google may select a different canonical, and URL Inspection shows which one it chose.

How do I add a canonical tag to a PDF?

Send it as an HTTP response header, because a PDF has no HTML <head>. The header takes the form Link: <https://example.com/page/>; rel="canonical", set in your server or CDN configuration for that file. Confirm it with curl -I against the PDF URL.

Can a page have both a canonical tag and hreflang tags?

Yes, and multilingual pages should have both. Each language version carries a canonical pointing to itself plus the full set of hreflang alternates. Never canonicalise a translated page to another language version, because translated pages are not duplicates.