Choose a canonical URL while keeping meaningful query values
Admin ·
A canonical declaration identifies the preferred address for duplicate or substantially similar content. Use your site's URL rules to decide which changes make sense before adding the declaration to your page or response.
Keep meaningful parameters in a campaign URL
Select Load example, then Generate canonical. The example starts with http://www.garden.example/Guides/Seed-Swap/?view=map&utm_source=mail&lang=en#details. The selected settings switch to HTTPS, remove www. and the fragment, remove the campaign parameter, and sort the remaining query names.
The preferred URL reads https://garden.example/Guides/Seed-Swap/?lang=en&view=map. It keeps the mixed-case path, trailing slash and both content options. Disable Sort query names to preserve the source order of lang and view.
| Input detail | Expected result |
|---|---|
| utm_source=mail | Removed by the selected campaign rule |
| lang=en and view=map | Kept in the preferred URL |
| /Guides/Seed-Swap/ | Path case and trailing slash preserved |
| #details | Fragment removed |
Google Search Central on specifying a canonical URLWHATWG URL Standard
Compare the two ways to publish the declaration
HTML link element gives a link tag for the HTML head. The text & between query fields is HTML escaping. An HTML parser reads the URL with the original ampersand.
Switch Output format to HTTP Link field. The exported field uses an angle-bracketed URL with a literal ampersand and a canonical relation. Use this representation when your server sends the canonical for a non-HTML file such as a PDF.
Google Search Central on specifying a canonical URLRFC 8288, The Link Header Field
Check the declaration against the published page
Place the HTML link in the head of the duplicate page or configure the equivalent response header. Use Canonical URL Checker with the saved HTML to see whether the link placement and resolved URL match your preferred address.
Check that other signals point to the same version where applicable. A different path case, trailing slash or query can identify different content on some servers. The generated declaration is a signal to search engines, which can choose a different canonical.
Google Search Central on specifying a canonical URLRFC 6596, The Canonical Link Relation
Common questions
Can I copy the escaped HTML URL into a Link response header?
Use the HTTP Link field output. It writes the raw query separator between fields, while the HTML output escapes it for an attribute.
What happens to repeated query names when I sort?
The generator orders fields by name while keeping the original order and value spelling for repeated names.
When should I keep a query parameter?
Keep a parameter when the preferred page requires it to select a language, product or view. Remove campaign parameters when they track visits to otherwise equivalent content.