facebook-opengrapharticle

What is the correct implementation of the Open Graph "article" type?


I need to add Open Graph tags to a blog page. It seems from reading the spec (http://ogp.me/) using an og:type of article is the way to go. However, I find the spec unclear and I'm unsure how to implement the syntax correctly.

Two example websites implement this differently for example:

  1. 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 the og and article namespaces are registered and that og and article are used as properties.

  2. BBC News article

    <head>
    <meta property="og:title" content="...">
    <meta property="og:type" content="article">
    <meta property="og:article:author" content="...">
    

    Note no namespace registration and og and og:article are used as properties.

  3. A variation I've seen in the wild of the above, registering only the og namespace and still referencing og: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 this. When I ran it through the Facebook validation tool I was told:

Objects of this type do not allow properties named 'og:article:published_time'.

For the moment, I have gone with option 1 and although this validates, I would like to know what the definitive correct syntax is?


Solution

  • Have a look at the Facebook developers documentation which is referring to the opengraph standard.

    It looks like your examples 2 and 3 have incorrect formatting. None of the "article" properties should begin 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' />