Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do canonical links require a full domain?

I want to add canonical links to my pages, but do I need to specify the domain, or will a relative URL do?

In other words, is:

<link rel="canonical" href="/item/1">

good enough, or do I need to use:

<link rel="canonical" href="http://mydomain.com/item/1">
like image 501
Richard Avatar asked Dec 11 '11 22:12

Richard


People also ask

Can you Canonical to a different domain?

What's more, you can even use rel=canonical across different domains. In other words, you can have one “canonical URL” (or “preferred” version of a web page) replicated on more than one other domain – allowing you to, for example, distribute certain content across several sites.

How do canonical links work?

A canonical tag (aka "rel canonical") is a way of telling search engines that a specific URL represents the master copy of a page. Using the canonical tag prevents problems caused by identical or "duplicate" content appearing on multiple URLs.

Does every page need a canonical URL?

Do include a canonical tag on every page, without exception. All pages (including the canonical page) should contain a canonical tag to prevent any possible duplication. Even if there are no other versions of a page, then that page should still include a canonical tag that links to itself.

What is a canonical URL why is it required?

A canonical URL is the URL of the best representative page from a group of duplicate pages, according to Google. For example, if you have two URLs for the same page (such as example.com? dress=1234 and example.com/dresses/1234 ), Google chooses one as canonical.


4 Answers

Directly from Google:

http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394

Can the link be relative or absolute?
rel="canonical" can be used with relative or absolute links, but we recommend using absolute links to minimize potential confusion or difficulties. If your document specifies a base link, any relative links will be relative to that base link.

like image 94
Remy Avatar answered Oct 02 '22 17:10

Remy


Again, Google says this:

https://support.google.com/webmasters/answer/139066?hl=en

Avoid errors: use absolute paths rather than relative paths with the rel="canonical" link element.

Use this structure: https://www.example.com/dresses/green/greendresss.html

Not this structure: /dresses/green/greendress.html).

For example’s sake, these are their URLs:

http://example.com/wordpress/seo-plugin/

http://example.com/wordpress/seo/seo-plugin/

This is what rel=canonical was invented for. Especially in a lot of e-commerce systems, this (unfortunately) happens fairly often, where a product has several different URLs depending on how you got there. You would apply rel=canonical in the following method:

You pick one of your two pages as the canonical version. It should be the version you think is the most important one. If you don’t care, pick the one with the most links or visitors. If all of that’s equal: flip a coin. You need to choose.
Add a rel=canonical link from the non-canonical page to the canonical one. So if we picked the shortest URL as our canonical URL, the other URL would link to the shortest URL like so in the <head> section of the page:

<link rel="canonical" href="http://example.com/wordpress/seo-plugin/">

That’s it. Nothing more, nothing less.

like image 33
Josip Ivic Avatar answered Oct 02 '22 15:10

Josip Ivic


All href attributes are hypertext references - that's what it stands for. As such, they are always URI-References, not URIs, and can be relative.

In this case though, there's a benefit in putting in the full URI if you can, because it will survive anything that migrates it onto another domain in the future (assuming you will still want the domain listed to be the canonical one), and can even survive some of the cruder automated plagiarisms :)

That benefit is pretty slight if you aren't actively using non-canonical versions on other domains though, so I wouldn't expend much effort on it.

like image 22
Jon Hanna Avatar answered Oct 02 '22 17:10

Jon Hanna


There is nothing special about canonical. It’s a standard link type, for use with standard ways to provide links (e.g., the link element), so you can specify any kind of URL reference (absolute, relative, protocol-relative, in combination with the base element, empty, …).

RFC 6596 (The Canonical Link Relation) explicitly says:

The target (canonical) IRI MAY:

  • Specify a relative IRI (see [RFC3986], Section 4.2).

One of the examples:

[…] or as a relative IRI:

<link rel="canonical" href="page.php?item=purse">
like image 20
unor Avatar answered Oct 02 '22 16:10

unor