HTML - Canonical URL

1 - What is a Canonical URL

A canonical url is a URL that has canonical value for a web page meaning that the value should be unique on the internet scope.

This value should never change and represent the unique identifier of the web page for its whole life time.

The Facebook graph uses this value as identifier for a web page

3 - Why you can get different URL for the same resource

3.1 - 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.

3.2 - Published in the category

The same page may be published in a category

3.3 - Syndication

The same page may be syndicated (published on another site)

3.4 - Translation

3.5 - 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.

3.6 - Moving a page

Moving a page to another URL without losing integrated components such as embedded discussion components.

4 - 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)

5 - Language

A link rel canonical is a link html element with a rel attribute.


<link rel="canonical" href="https://gerardnico.com/cat/post1" />

Once created the value https://gerardnico.com/cat/post1 should never change even if the page get a new URL

Make sure that you use:

for the canonical href value.

The pages do not need to be absolutely identical. They just need to serve the same content.

5.2 - 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" />

6 - Documentation / Reference


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap