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 Facebook graph uses this value as identifier for a web page
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.
The same page may be published in a category
The same page may be syndicated (published on another site)
A page may be translated.
Tell Google about localized versions of your page
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 to another URL without losing integrated components such as embedded discussion components.
A Rel canonical is a tag in the header in a HMTL page that tells search engines:
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:
for the canonical href value.
The pages do not need to be absolutely identical. They just need to serve the same content.
The og:url open graph property served the same goal. Facebook uses it
<meta property="og:url" content="https://example.com/path" />