How to Set a Canonical URL
current Google Search Console, Bing Webmaster Tools, and major hosts · Last checked · Suggest an edit
https://instructions.wiki/web/set-a-canonical-url
The same page is often reachable at more than one address: with and without www, with a trailing slash, with tracking parameters, over http and https. Search engines see each as a separate page and split the ranking between them. A canonical tag tells them which one counts.
Pick the one true URL for each page
Decide on a single format and use it everywhere: https, with or without www (pick one), and with or without a trailing slash (pick one). For example:
https://yourdomain.com/about
Every internal link, sitemap entry, and redirect should use this exact form.
Add the canonical tag to the head
Inside <head> on every page, add a link tag pointing at that page's true URL:
<link rel="canonical" href="https://yourdomain.com/about" />
The URL must be absolute, including the scheme and domain. Relative paths are ignored by some crawlers.
Make every page self-referencing
A page's canonical should point at itself, not at the homepage or a category. about points to about. Pointing many pages at one URL tells Google those pages are duplicates and drops them from results.
The exceptions are true duplicates: a print version, a ?ref= tracking variant, or a syndicated copy. Those point at the original.
Redirect the other versions
A canonical is a hint. A redirect is a rule. Set your server or host to 301-redirect http to https and www to non-www (or the reverse) so the alternate addresses do not exist as separate pages at all.
Check it in Search Console
Paste a URL into the search bar at the top of Google Search Console. The Page indexing section shows the User-declared canonical (yours) and the Google-selected canonical (what Google decided). They should match. If they do not, Google is seeing a conflict somewhere, usually a redirect or sitemap that disagrees with the tag.
One per page. If a page has two canonical tags, Google ignores both. Check for a CMS or plugin adding one you did not know about.