Learn
Canonical Tag Example: HTML Syntax and What It Is Used For
A canonical tag names the preferred URL among duplicates. It is a hint Google weighs against other evidence, not an instruction it must obey.
Run a fresh DomainLens audit and use the report as your priority list.
Canonical tag meaning
A canonical tag tells search engines which URL is the preferred address for a piece of content when several URLs serve the same thing. It exists because the same page routinely has more than one address: with and without a trailing slash, with tracking parameters, with sort or filter values, or under two categories.
The important nuance is that it is a hint rather than a directive. Google weighs your declaration against internal links, sitemap contents, redirects, and the similarity of the pages themselves. When the other evidence points elsewhere, Google picks a different canonical and reports it as the Google-selected canonical.
Canonical tag in HTML: the syntax
The tag is a single link element in the head. Placement matters: it must be inside the head, and it must be the only canonical the page declares.
- Use an absolute URL including the scheme and host. Relative values are legal but easy to resolve incorrectly.
- Declare exactly one canonical per page — two conflicting tags cause Google to ignore both.
- The tag must be in the head. A canonical injected into the body is disregarded.
- Point at a URL that returns 200. A canonical aimed at a redirect or a 404 is discarded.
- Every indexable page should carry a self-referencing canonical, so the preferred form is stated even when no duplicate exists yet.
<head>
<!-- Self-referencing canonical: the normal case -->
<link rel="canonical" href="https://example.com/guides/technical-seo">
</head>
<!-- For a non-HTML resource such as a PDF, use a header -->
Link: <https://example.com/guides/technical-seo>; rel="canonical"Canonical tag examples by scenario
| Situation | Canonical should point to | Why |
|---|---|---|
| Tracking parameters on a URL | The clean URL without parameters | The content is identical |
| Sorted or filtered listing | The unfiltered listing | Variants add no distinct value |
| Paginated series | Each page to itself | Page 2 is not a duplicate of page 1 |
| Same product in two categories | One chosen category path | Consolidates split signals |
| Printer-friendly version | The standard version | Same content, lesser presentation |
| Syndicated copy on another domain | The original URL | Credits the source |
<!-- On https://example.com/shoes?utm_source=newsletter -->
<link rel="canonical" href="https://example.com/shoes">
<!-- On https://example.com/shoes?page=2 -->
<!-- Self-referencing: page 2 is its own content -->
<link rel="canonical" href="https://example.com/shoes?page=2">What canonical tags are used for in SEO
What they are not for is equally important. A canonical does not block crawling, does not remove a page from the index, and does not redirect a user — the page stays reachable and fully readable at its own URL. Reaching for a canonical when you actually need a redirect or a noindex is one of the most common causes of pages that will not disappear from search.
- Consolidating ranking signals from several URLs onto one preferred address.
- Preventing near-identical pages from competing with each other for the same query.
- Telling Google which URL to display in results when duplicates exist.
- Reducing wasted crawl on parameter variants that add nothing.
Canonical tag checker: verifying what a page declares
Checking a canonical means reading the rendered value, not the template. On a client-rendered site a script can overwrite or duplicate the tag after load, so the source HTML and the DOM can disagree.
- 1Read the canonical from the rendered HTML, not just the source, and confirm there is exactly one.
- 2Confirm the target returns 200 and is not itself redirected or canonicalised elsewhere.
- 3Check that internal links and the sitemap point at the same URL the canonical names.
- 4Compare the declared canonical with the Google-selected canonical in URL Inspection.
- 5Sample by template rather than by page — canonical bugs are almost always template-wide.
# The declared canonical in the served HTML
curl -s https://example.com/shoes \
| grep -oE '<link[^>]+rel="canonical"[^>]*>'
# Count them — more than one is a bug
curl -s https://example.com/shoes | grep -c 'rel="canonical"'Canonical tag generators and template rules
A canonical generator produces a single tag for a single URL, which is fine for a one-off check and useless as a strategy. Canonicals are a template concern: the rule that builds them has to be correct once, for every page the template renders, including the parameter and pagination cases.
Write the rule as "the current URL, stripped of ignorable parameters, in the site's preferred host and slash form", and test it against the awkward URLs rather than the tidy ones. If the rule is right, no page ever needs a hand-written canonical.
How DomainLens contributes
DomainLens reports the canonical a page actually serves, flags pages declaring more than one, and checks whether the target resolves — the three failures that make a canonical silently inert. When your declaration and Google's selection disagree, work through canonical tag problems, compare the alternatives in canonical vs noindex, and read the selection itself in URL Inspection.
- What does a canonical tag do?
- It names the preferred URL among duplicates so ranking signals consolidate onto one address. It is a hint Google weighs against other evidence rather than an instruction it must follow.
- Should every page have a self-referencing canonical?
- Yes, on every indexable page. It costs nothing, states the preferred URL form explicitly, and protects against parameter variants appearing later.
- Can a canonical tag point to a different domain?
- Yes. Cross-domain canonicals are the standard way to credit an original when content is syndicated elsewhere.
- Why is Google ignoring my canonical tag?
- Because it is a hint. If internal links, the sitemap, or redirects point at a different URL, Google follows the stronger evidence. Align those signals rather than re-declaring the same tag.