skip to Main Content

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

<link rel="canonical" href="//example.com" />

I redirect all users to HTTPS anyway.

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

4

Answers


  1. I believe you can’t, according to this website.

    Make them 100% specific. For various reasons, a ton of sites use protocol relative links, meaning they leave the http / https bit from their URLs. Don’t do this for your canonicals. You have a preference. Show it.

    Also, I’d recommend the https, because Google is using it as a ranking signal.

    Login or Signup to reply.
  2. If the spec co-written by Google employees (https://www.rfc-editor.org/rfc/rfc6596) is correct, then yes, any relative reference is ok.

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
  4. Yes you can – both the spec and Google will allow a uri as a canonical href.

    This does present a risk that your page is reached via the wrong protocol – eg: http page is visited when you want https canonical url’s. In this case the relative canonical value is interpreted as an http url.

    However, if you have your 301 redirects correctly set up to go from http to https, you will not have an issue, and it may actually be preferable in some cases to use a relative canonical url.

    Case in point, switching from an http site to https will lose you all your Facebook likes accumulated on your http url’s. In this case you may want Facebook to still crawl your http site, whilst redirecting all other user agents to https.

    Facebook will then reinstate your old http page likes on both your http and https pages, but not if your page’s canonical url points to an absolute https url. In this instance a protocol relative canonical url – //www.mysite.com – is very useful.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search