What is the correct implementation of the Open Graph "article" type?
I need to add Open Graph tags to a blog page. It seems like reading the spec ( http://ogp.me/ ) with og:type
of article
is the way to go. However, I find the specification unclear and I'm not sure how to properly implement the syntax.
Two sample websites implement this differently, for example:
-
Example from GitHub: ( https://github.com/niallkennedy/open-graph-protocol-examples/blob/master/article-utc.html )
<head prefix="og: http://ogp.me/ns# article: http://ogp.me/ns/article#"> <meta property="og:title" content="..."> <meta property="og:type" content="article"> <meta property="article:published_time" content="...">
Note that the namespaces
og
and arearticle
registered and thatog
andarticle
are used as properties. -
BBC News article
<head> <meta property="og:title" content="..."> <meta property="og:type" content="article"> <meta property="og:article:author" content="...">
Note. Namespace registration and
og
and are not used as propertiesog:article
. -
A variation I saw in the wild above, registering only the namespace
og
and still referencingog:article
as a property.<head prefix="og: http://ogp.me/ns#"> <meta property="og:title" content="..."> <meta property="og:type" content="article"> <meta property="og:article:published_time" content="..">
Option 3 is what I used the first time I tried to implement it. When I ran it through Facebook's validation tool, I was told:
Objects of this type do not allow properties named "og: article: published_time".
At the moment I went with parameter 1, and although it is confirmed, I would like to know what the final correct syntax means?
source to share
Take a look at the Facebook developers page: https://developers.facebook.com/docs/reference/opengraph/object-type/article
It looks like your examples 2 and 3 are not formatted correctly. None of the "article" properties should start with "og:"
Here's what I have on one of my sites and I get no errors from the FB debugger:
<meta property='og:type' content='article' />
<meta property='article:author' content='https://www.facebook.com/YOUR-NAME' />
<meta property='article:publisher' content='https://www.facebook.com/YOUR-PAGE' />
<meta property='og:site_name' content='YOUR-SITE-NAME' />
source to share
This is an example from http://ogp.me/#array
<meta property="og:image" content="http://example.com/rock.jpg" />
<meta property="og:image:width" content="300" />
<meta property="og:image:height" content="300" />
<meta property="og:image" content="http://example.com/rock2.jpg" />
<meta property="og:image" content="http://example.com/rock3.jpg" />
<meta property="og:image:height" content="1000" />
source to share
you can post this code to your blog or article header
<meta property="article:publisher" content="https://www.facebook.com/author/"/>
<meta property="article:published_time" content="2017-11-26T17:41:45+00:00" />
<meta property="article:modified_time" content="2017-11-27T00:32:23+00:00" />
<meta property="og:updated_time" content="2017-11-27T00:32:23+00:00" />
source to share