Can I use a "protocol free" URL with rel=canonical?

- 1 answer

Ad

SEO wise, is it okay to use an protocol free URL like this?

<link rel="canonical" target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="//example.com" />

I redirect all users to HTTPS anyway.

With protocol free I mean not using either http:// or https:// but // instead.

Ad

Answer

Ad

Yes

href attribute on a canonical link is like all href attribute on <link>: it supports URIs. And URIs can be full URIs or relative URIs.

Moreover The Canonical Link Relation spec confirms that.

Then: of course you can use a relative URL like a protocol free one.

But don't

I will recommend anyway to always use full URLs : scheme, host, path...

Why ? Because canonical URL is made to prevent from wrong URL to be used by robots.

Then using a relative URL might let some wrong URLs used by bots contrary to a full URL which you can be certain it is the right one.

Ad
source: stackoverflow.com
Ad