What is a Canonical URL
A canonical url is a URL that has a canonical value identifier for a web page meaning that the value should be unique on the internet scope.
This is the URL that people will see in:
- the search results. 1)
- the sitemap
The Facebook graph uses this value as identifier for a web page
Why you can get different URL for the same resource
Friendly URL
The same page may have different URL such as:
The link rel canonical defines which one is the good identifier and don't let robot such as google search defines it by chance.
Published in the category
The same page may be published in a category
Syndication
The same page may be syndicated (published on another site)
Translation
A page may be translated.
Mobile vs Desktop
A Mobile page and desktop page may not be served from the same domain and link canonical permits to identify them as the same resource.
Moving a page
Moving a page to another URL without losing integrated components such as embedded discussion components.
Specification
A Rel canonical is a tag in the header in a HMTL page that tells search engines:
- which piece of content is the original and which one is a duplicate. It has been created in order to avoid duplicate content
- which operates exclusively on a single root domain (it will carry over across subfolders and subdomains, not cross domain)
Language
link rel
A link rel canonical is a link html element with a rel attribute.
<link rel="canonical" href="https://datacadamia.com/cat/post1" />
Once created the value https://datacadamia.com/cat/post1 should never change even if the page get a new URL
Make sure that you use:
- an absolute path (https://domain/path)
- rather than a relative path (path)
for the canonical href value.
The pages do not need to be absolutely identical. They just need to serve the same content.
og:url meta property
The og:url open graph property served the same goal. Facebook uses it
<meta property="og:url" content="https://example.com/path" />
Documentation / Reference
- Specification: Rfc6596 - The Canonical Link Relation