Canonical tag
A canonical tag (rel="canonical") is an HTML element that tells search engines which version of a page is the preferred one to index when duplicate or near-duplicate URLs exist.
Updated , every quotation and figure read in its source that day.
When the same content is reachable at several URLs, search engines pick one to show: the canonical URL. A canonical tag, <link rel="canonical" href="...">, is how you tell Google which one you prefer. It is a strong hint, not an order.
What a canonical URL is
Google defines canonicalization as the process of selecting the representative URL of a piece of content, and a canonical URL as "the URL of a page that Google chose as the most representative from a set of duplicate pages". Duplicates are common and often innocent: regional variants, mobile and desktop versions, HTTP and HTTPS, sorting and filtering parameters, a demo site left open. "Some duplicate content on a site is normal and it's not a violation of Google's spam policies" (What is URL canonicalization).
How Google chooses, and how strong each signal is
Google clusters pages with the same or very similar main content and picks the one that is, on the signals it collected, "the most complete and useful for search users". Those signals include HTTPS versus HTTP, redirects, sitemaps and rel="canonical" annotations, and Google is explicit that "indicating a canonical preference is a hint, not a rule" (Google).
It ranks the methods you control by strength: a redirect is "a strong signal that the target of the redirect should become canonical", a rel="canonical" annotation is "a strong signal that the specified URL should become canonical", and including a URL in a sitemap is "a weak signal". The methods "can stack", so they work best together (How to specify a canonical URL). A permanent 301 redirect is the stronger choice when the old URL does not need to stay accessible.
How to declare a canonical
Put a <link rel="canonical" href="https://example.com/page"> element in the <head> of each duplicate, pointing to the preferred URL, or send the same information in a Link HTTP header for files such as PDFs. Google recommends absolute URLs rather than relative paths in both (Google). Many sites also give every page a canonical tag pointing to itself, so that parameter variants have a clear target.
Mistakes Google warns about
Do not use robots.txt for canonicalization: Google "may still index URLs that are disallowed in robots.txt without their content". Do not use the URL removal tool, which hides every version of a URL. And do not use noindex to choose a canonical within a site, "because it will completely block the page from Search"; rel="canonical" is the preferred solution (Google).
How to see which URL Google chose
Search Console's URL Inspection tool shows it: inspect the indexed version of a page and read the Google-selected canonical field. Only the indexed data tells you; the live test cannot predict which version Google will choose (URL Inspection tool, Search Console Help). Google says canonicalization helps it consolidate the signals of duplicate URLs, such as the links pointing to them, into the preferred one (Google), which is one more reason to keep your own internal links on the canonical version.