3

I've been using the double-slashed, protocol-independent, version of URLs systematically whenever I can for a while now, in HTML (for href on anchors and src on images) and in JS (for XHR). Today I have been wondering if this would be possible on OpenGraph tags.

Currently I have this:

<meta property="og:image" content="http://static.example.com/image.png">
<meta property="og:url" content="http://example.com">

I have been wondering what the effect of using the following would be:

<meta property="og:image" content="//static.example.com/image.png">
<meta property="og:url" content="//example.com">
  • Is this allowed by the spec?
  • Is this allowed by (major) implementations?
  • Are there any obvious issues I'm not seeing?
  • Am I thinking about this completely wrong?
  • Has anyone done this or tried this before?

Okay, that's a bit too many questions, but you can see where I'm going: should I (and other developers who might chance upon this) use explicit protocols or is it okay to leave them off for og:* properties?

Félix Saparelli
  • 8,424
  • 6
  • 52
  • 67

2 Answers2

3

By adding these meta elements with the property attribute to your page, you are using RDFa (which is a serialization format of RDF). So you are participating in the Semantic Web.

The fundamental idea of the Semantic Web is using URIs to describe things represented by URIs. Some URIs represent web pages (we all know these), while other URIs represent real world or abstract things (like the person J. R. R. Tolkien, the concept of love, or the Eiffel Tower). (See this answer on how you could distinguish these.)

For example, this URI represents the physical world building (not a web page about that building):
http://dbpedia.org/resource/Eiffel_Tower

The HTTPS variant (https://dbpedia.org/resource/Eiffel_Tower) would be a totally different URI, which could, in principle, be used for something unrelated like a football or so. For RDF (in contrast to the common practice in the Web), there is no relation between a HTTP URI and its HTTPS counterpart.

So when you provide RDF statements about both URIs, it’s (at first) not clear that both are referring to the same thing. When you use an unique object for both URIs, then these could be mapped to mean the same thing. You can also explicitly specify with OWL (→ owl:sameAs) that two URIs are representing the same thing.

So, it’s not forbidden or wrong, but I’d advise to use only one of your "synonymous" URIs for a page/thing. Other people may want to make RDF statements with your URIs (→ things/pages), so it’s better that they all use the same ones.

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
-1

No, it's wrong. Why? Facebook parser don't know how protocol use on site.

zardoz
  • 395
  • 1
  • 3
  • 8