A canonical tag is a small piece of code embedded into a webpage that can help search engines deal with multiple versions of the same page. It is supported by three of the most popular search engines and allows webmasters to specify a preferred address for content that might be duplicated. Search engines usually honor this request and use the preferred address when indexing pages, but may ignore it under certain circumstances. Canonical tags, which are actually an element of the <link> tag, can be used with both relative and absolute paths but generally cannot go across domains.
In early 2009, three major search engines agreed to use the canonical tag to help deal with duplicate content on the web. Similar or identical webpages can often be accessed from multiple web addresses, or Uniform Resource Locators (URLs), such as http://example.com, http://www.example.com, and http://www.example.com/index.php. Content management systems, e-commerce platforms, and wiki software may also generate pages dynamically, with slightly different URLs being used to change the sorting order of a category, track affiliate links, or access previous versions of an article or page.
Duplicate pages with slightly different addresses can work against the search engine algorithms that use link popularity to determine where a page ranks in search results. A webpage with 300 links pointing at two different URLs might appear to a search engine’s indexing software as a single page with only 150 links. Search engines have historically dealt with the problem by offering preferred URL settings in their webmaster tools, developing their own internal algorithms to guess the most appropriate address, and obeying 301 redirects, a server-generated status code that forwards requests to a new URL.
The canonical tag is a way for web developers to mark a particular URL as the preferred version of a page. It is a small snippet of code that must be inserted into all webpages with similar or duplicate content, but does not require any changes to a web server’s settings. Most search engines treat it as a “strong hint” rather than a command, meaning that a canonical tag that has been implemented poorly or points to a completely different page might be ignored. The code is only meaningful to search engines; web browsers disregard canonical tags.
Despite its name, a canonical tag is not a true “tag” but an element that can be applied to the widely used <link> tag. A page marked with the code <link rel="canonical" href="http://www.example.com/about.html"/> would tell a search engine that the preferred or canonical URL for the content is http://www.example.com/about.html. The "rel=canonical" portion of the code tells a search engine that the URL in the "href=" is a canonical link. Unlike a 301 redirect, a canonical tag can be used with both absolute and relative paths, although some search engines recommend using absolute paths. The 301 redirects, however, can point to a different domain, while most search engines only support canonical links on the same domain.