2

Is it a problem to put a schemaless URL in a canonical tag?

Example: page URL is http://example.com while canonical tag is <link rel="canonical" href="//example.com" />.

2

It’s technically allowed:

  1. RFC 6596 allows relative URLs:

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

  2. RFC 3986 defines that a protocol-relative URL is some kind of relative reference:

    A relative reference that begins with two slash characters is termed a network-path reference […]

It can become a problem if the document is accessible from more than one scheme/protocol. So if you have a HTTP and a HTTPS version (and you don’t redirect one to the other), you end up with two different canonical URLs, which defeats the purpose of using canonical.

Also note that you don’t necessarily have control over the protocols. For example, if someone downloads your document (that contains a protocol-relative canonical URL) and uses it locally (file: scheme), the canonical URL wouldn’t point to your HTTP/HTTPS URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.