When there are multiple URLs associated with one particular piece of content, duplication occurs. Canonical tags are used to help search engines understand which URL has authority over others. This increases the likelihood of important pages being crawled, indexed, and ranked.

If the different URLs need to be accessible (e.g. navigation paths, parameters URLs, session IDs, etc.), using canonical tags helps identify which URL is the canonical, authoritative version so equity can be consolidated to one URL. This can lead to stronger pages and better rankings.

If the website configuration generates duplicate URLs that do not need to be accessed by users or search engines, 301 redirects should be implemented to automatically send visitors and crawlers to the authoritative version of the page.

It is important to note that a canonical tag is a hint and search engines might not respect it if other aspects of the site, such as URLs specified in an XML Sitemap or the overall internal linking, send opposite signals.

Implementation of the canonical tag

The rel="canonical" tag must appears in the <head> section of the HTML page. Note that the href attribute-value pair needs to be the fully qualified domain name (or "absolute" URL).

Code example

<head>
  <link rel="canonical" href="http://www.example.com/authoritative-page/">
</head>

Alternatively, the tag can be implemented as an HTTP response header. This is particularly useful for instances like PDFs.

In the HTTP response header of a .pdf document

HTTP/1.1 200 OK
Content-Type: application/pdf
Link: <http://www.example.com/authoritative-webpage-version-of-the-pdf-document.html>; rel="canonical"

Self-referencing canonical tags

As a rel attribute of a <link> element, the canonical tag establishes a relationship between two URLs.
For example, page A and page B serve identical (or nearly identical) content, page A is the authoritative version and both need to be accessible.
Page B should include the following tag pointing to page A:

In the <head> section of page B

<link rel="canonical" href="http://www.example.com/page-a/">

Additionally, in order to re-enforce the signal sent to search engines, page A should include a self-referencing canonical tag (pointing to itself).

In the <head> section of page A

<link rel="canonical" href="http://www.example.com/page-a/">

Note that canonical tags and noindex tags serve different purposes and signals can conflict, especially if a canonicalized URL is noindex.