A canonical URL is the one address you want a search engine to treat as the main copy when the same page opens at several URLs. You declare it with a link rel=canonical element in the head. It is a hint. A 301 is a separate tool. www, http and parameter URLs are the usual duplicates.
Why the same page has several URLs
One article can open with www and without it, on http and on https, and with a tracking parameter stuck on the end. The words on the screen match. The addresses do not. A search engine then has to pick a main copy.
The rel=canonical tag
In the head of the duplicate, add a link element whose rel is canonical and whose href is the full https address you want indexed. Use the absolute URL, including the scheme and host. A page you care about should also point the tag at itself, so the signal is explicit.
Example shape: link rel=canonical href=https://example.com/page/
A 301 redirect is a different tool
A 301 sends the visitor and the crawler to the other address. The canonical tag leaves the visitor on the URL they opened and asks the crawler to treat another URL as the main copy. Use the redirect when only one URL should exist. Use the tag when both URLs must keep working, such as a sorted catalogue.
www, parameters and mixed signals
Pick www or the bare host and stay with it. The pair is covered on www versus non-www. If the sitemap, the internal links and the tag name three different URLs, the hint is weak. SEO services is the service when you want that cleaned up on a whole site. A practical on-page list is the local SEO checklist.
Frequently Asked Questions
What is a canonical URL?
It is the address you ask a search engine to treat as the main copy when the same page opens at several URLs.
What does the canonical tag look like?
A link element in the head with rel=canonical and an href of the full https URL you want indexed.
Is a canonical tag the same as a 301 redirect?
A 301 sends the visitor to the other address. The tag leaves the visitor in place and asks the crawler to prefer one URL.
What is a non-canonical URL?
Any address for that page which is not the one you named in the tag, such as the www twin, the http twin, or a URL with a tracking parameter.

