Skip to the tool
OnPageKit

Canonical Tag Generator

Normalise a URL into a rel=canonical line.

the address this page should be known by

The fragment is always dropped, and the host is always lower-cased. The path is not: a server may well treat /Pricing and /pricing as two different pages.

inside <head>
for PDFs and other non-HTML files

Everything runs in your browser. Nothing you type is sent to a server.

Found a bug in this tool? Report it.

Share this tool

What this canonical tag generator actually does

Paste an address and this canonical tag generator rewrites it into the one form you want indexed: scheme forced to https, www added or removed consistently, the fragment discarded, campaign parameters stripped, the trailing slash settled one way. It then prints both declarations — the <link> element for a page and the Link response header for a file that has no head — with the href escaped as an HTML attribute rather than pasted raw.

Duplicates are made by accident

Almost nobody sets out to publish the same page twice. It happens because a URL has more moving parts than people count: http and https, with and without www, with and without a trailing slash, uppercase and lowercase in the path, and any number of parameters bolted on by a newsletter or an ad platform. Every combination is a distinct address, and each one that gets crawled and linked competes with the rest for the same content.

The tool lower-cases the host because host names are case-insensitive by specification. It leaves the path alone, because paths are not — plenty of servers really do return different things for /Pricing and /pricing, and quietly rewriting one into the other would produce a canonical pointing at a 404.

A hint, weighed against everything else

Treating rel="canonical" as a command is what makes it disappointing in practice. Google consolidates a duplicate cluster onto one representative, and the canonical is one voice in that decision alongside internal links, the sitemap, redirects and hreflang.

That has a practical consequence: contradicting yourself is worse than saying nothing. Linking internally to /product?colour=blue while canonicalising to /product, or listing both in the sitemap, gives the crawler a reason to disregard the hint entirely. Say the same thing in every channel and the hint is nearly always taken.

Two ways to get it wrong quietly

The first is emitting two of them. A theme writes one canonical, a plugin writes another, and the head ends up with a pair that disagree — at which point both are ignored. This is common enough that the tool has a checkbox for it, because you can only find out by viewing the rendered source of a live page.

The second is combining a canonical with noindex on the same page. One asks for signals to be consolidated onto this address; the other asks for the address to be dropped. Google resolves the contradiction unpredictably, so pick whichever you actually meant and delete the other.

Cross-domain, files and pagination

Syndication is the honest use of a cross-domain canonical: a partner republishes your piece and points their copy at yours. It works only when the content really matches and the target is indexable — a canonical aimed at a redirect chain, or at a page you have excluded, is discarded.

For a PDF, a spreadsheet or an image there is no head to write into, and the response header is the only route. The syntax is fussy — angle brackets around the URL, a semicolon, then the relation — which is why the second output box exists.

Get the internationalised set right at the same time: canonical and hreflang have to agree, because each hreflang alternate is expected to canonicalise to itself. If the page carries structured data too, the product schema generator and the local business schema generator should reference this same address rather than a variant of it.

Frequently asked questions

Is rel=canonical a directive Google has to obey?

No. It is a hint, weighed against the other signals that say which address represents a group of duplicates: internal links, the sitemap, redirects, hreflang, and which version is served over https. When the hint agrees with all of them it is nearly always honoured. When it disagrees, Google picks its own representative and reports the choice in Search Console.

Should a page point a canonical at itself?

Yes, on every indexable page. A self-referencing canonical costs nothing and settles the case a template cannot foresee — someone linking to your page with a campaign parameter, a session id, or an uppercase path. Without it, whichever variant gets crawled and linked first can end up as the indexed one.

How do I give a PDF a canonical?

Through the HTTP response, since there is no head element to put an attribute in. Send Link with the URL in angle brackets and rel="canonical" after a semicolon, which is what the second box on this page produces. The same mechanism works for images and any other non-HTML file your server returns.

Can a canonical point at a different domain?

It can, and syndication is what it is for: a partner republishing your article points their copy at yours, and the signals consolidate on the original. Two conditions make it work — the content has to genuinely match, and the target has to be indexable. Cross-domain canonicals to a page that redirects, or to a page nobody links to, tend to be ignored.

What should paginated pages canonicalise to?

Themselves. Page two of a listing is a distinct page with distinct items, and pointing it at page one tells Google the items on it do not need indexing. The old advice about a view-all page still holds where one genuinely exists, but the common mistake — every page in a series claiming to be page one — hides most of the catalogue.

Related tools

Updated