Skip to content
SocialTools

Canonical URL Tag Generator

Output a rel=canonical tag for the exact HTTPS URL you want indexed. Use it on duplicates, not as a substitute for redirects.

SEO ToolsSEOReviewed 2026-09-11 by SocialTools editorial. How we test
Canonical link tag
<link rel="canonical" href="https://example.com/page" />

Place this tag inside the <head> of your HTML document to tell search engines which URL is the preferred version of this page.

Runs in your browser. Nothing you enter is uploaded.

Overview

The same page is often reachable at several addresses. Add a tracking parameter, a session identifier, a trailing slash, an uppercase letter, or a print variant and you have another URL serving identical content - and a crawler with no way of knowing which one you consider authoritative. A canonical tag is how you tell it.

This generator produces that tag. Enter the URL you want treated as the definitive version and it emits a complete link element, with the URL escaped so it is safe to place inside an HTML attribute, ready to paste into your document head.

The tag is one line of markup and the decision behind it is not. Choosing the wrong canonical is worse than having none, because it actively instructs search engines to consolidate signals onto a page you did not mean.

Self-referencing canonicals and the duplicates they resolve

The default correct answer for most pages is a canonical pointing at themselves. A page whose canonical is its own clean URL is protected against every parameter variant that might be appended to it later: a link shared with UTM parameters, a filter state, a session token. All of them resolve back to the one URL you nominated, and the ranking signals consolidate there instead of scattering.

The cases where a canonical points elsewhere are specific. A paginated series where you want everything credited to the first page. A product available in several colourways at separate URLs where one is the primary. Syndicated content republished elsewhere, where the syndicated copy should point back at your original. In each of these the target page must be substantially the same content - a canonical is a claim about duplication, not a redirect and not a preference.

Pointing a canonical at a page with meaningfully different content is where real damage happens. Search engines may honour it and drop your page from the index in favour of the target, or may ignore it and treat every canonical on your site with more suspicion. Both outcomes are worse than the duplicate content you were trying to fix.

  • Default: every page canonicals to its own clean URL.
  • Point elsewhere only when the content is genuinely near-identical.
  • One canonical per page - multiple tags are ignored or resolved unpredictably.
  • A canonical is a hint, not a directive; search engines can and do disregard it.

Absolute URLs, trailing slashes, and other ways to point at nothing

Use the full absolute URL including the scheme. A relative path is technically permitted and resolves against the current document, which works until the tag is served from an unexpected path and starts resolving somewhere wrong. Absolute URLs have no such failure mode and cost you nothing.

Be consistent about the details that create distinct URLs. https and http are different. www and the bare domain are different. A trailing slash and no trailing slash are different. Uppercase and lowercase paths are different on most servers. Whichever form your site actually serves - the one your redirects settle on - is the one the canonical must name, and mixing forms across your templates produces a site where every page canonicalises to a URL that immediately redirects.

That redirect chain is the most common self-inflicted error. A canonical pointing at a URL that 301s to another URL is asking a crawler to follow an indirection to find your preferred page, which weakens the signal and sometimes breaks it. Test the canonical you generate by loading it and confirming it returns 200 directly.

The escape pass and the validation warning

Your input is trimmed and passed through an attribute-escaping step that replaces ampersands with &amp;, double quotes with &quot;, and less-than signs with &lt;. Those three are the characters that would otherwise break out of the attribute or the tag, so escaping them is what makes a URL containing query parameters safe to embed. The escaped string is then wrapped in a complete self-closing link element with rel set to canonical.

Separately, the raw input is checked by attempting to construct a URL object from it. If that fails you get a warning that the format may be invalid - and the tag is still generated, deliberately, because the parser is stricter than some legitimate inputs and a warning is more useful than a refusal.

Nothing else is validated. The tool does not fetch the URL, does not check that it resolves, does not follow redirects, and does not compare the target’s content against the page you intend to put the tag on. It is a formatter with a syntax hint, running entirely in the browser.

A URL with an ampersand and a tracking parameter

Input

https://example.com/shop?category=mugs&colour=green

Output

<link rel="canonical" href="https://example.com/shop?category=mugs&amp;colour=green" />

The ampersand became &amp;, which is required - an unescaped ampersand inside an attribute is invalid HTML and can be mis-parsed. But the more important observation is that this is probably the wrong canonical to be generating. If the colour parameter does not change the page meaningfully, the canonical should be https://example.com/shop with no parameters at all, so that every filter combination consolidates onto one URL. The tool will faithfully format whatever you give it, including a canonical that fragments your signals rather than consolidating them.

Limitations

  • One URL at a time. There is no bulk mode for generating canonicals across a list of pages.
  • The URL is never fetched. No check is made that it resolves, returns 200, or avoids a redirect chain.
  • Invalid URLs produce a warning but still generate a tag, so a typo can be copied out unnoticed.
  • No content comparison is performed between the canonical target and the page the tag will go on.
  • Only the HTML link element is produced - not the HTTP Link header form, and not hreflang or alternate declarations.
  • Escaping covers ampersands, double quotes, and less-than signs. Other characters are passed through unchanged, so a URL with unencoded spaces stays broken.

When not to use this tool

  • If the duplicate URLs should not be reachable at all, a 301 redirect is the stronger and more appropriate fix.
  • If you are declaring language or regional variants rather than duplicates, hreflang annotations are the correct mechanism and a canonical is not.

How to use it

  1. 1

    Decide the one authoritative URL for the page, defaulting to the page’s own clean address without parameters.

  2. 2

    Write it as an absolute URL, matching the scheme, subdomain, casing, and trailing-slash convention your site actually serves.

  3. 3

    Generate the tag and place it in the document head, ensuring there is exactly one canonical element per page.

  4. 4

    Load the canonical URL directly to confirm it returns 200 without redirecting, and check it matches what your sitemap lists.

Questions

Should every page have a canonical tag?

A self-referencing canonical on every indexable page is a low-cost, low-risk default that protects against parameter variants appearing later. The alternative - adding canonicals only where you have noticed a duplicate - means you are always reacting to a problem after it has already split your signals.

Is a canonical the same as a redirect?

No. A redirect sends the visitor and the crawler to a different URL; a canonical leaves both where they are and expresses a preference about which URL should be indexed. If you do not want the duplicate URL to be reachable, redirect it. If you need it reachable but not indexed separately, canonicalise it.

Can search engines ignore my canonical?

Yes, routinely. It is treated as a strong hint rather than an instruction, and it is weighed against other signals - internal links, sitemaps, redirects, and whether the two pages really are duplicates. Contradicting your canonical elsewhere on the site is the usual reason one gets overridden.

Does the canonical URL need to match the sitemap?

It should. Listing a URL in your sitemap while canonicalising it to a different one sends two contradictory signals, and search engines resolve the contradiction however they judge best rather than however you intended. Sitemaps should contain canonical URLs only.