Open Graph“文章”类型的正确实现是什么?

问题描述 投票:10回答:3

我需要将Open Graph标签添加到博客页面。似乎从阅读规范(http://ogp.me/)使用og:type article是要走的路。但是,我发现规范不清楚,我不确定如何正确实现语法。

两个示例网站以不同方式实现此示例:

  1. 来自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="..."> 请注意,ogarticle名称空间已注册,ogarticle用作属性。
  2. BBC新闻文章 <head> <meta property="og:title" content="..."> <meta property="og:type" content="article"> <meta property="og:article:author" content="..."> 注意没有命名空间注册,ogog:article用作属性。
  3. 我在上面看到的一个变体,仅注册og命名空间,仍然引用og:article作为属性。 <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="..">

选项3是我第一次尝试实现它时使用的。当我通过Facebook验证工具运行时,我被告知:

此类对象不允许名为“og:article:published_time”的属性。

目前,我已经选择了1,虽然这有效,但我想知道确切正确的语法是什么?

opengraph article
3个回答
10
投票

看看Facebook开发者页面:https://developers.facebook.com/docs/reference/opengraph/object-type/article

看起来您的示例2和3的格式不正确。 “article”属性都不应以“og:”开头

这是我在我的一个站点上的内容,我从FB调试器中得到的错误:

<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' />

-1
投票

这是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" />

-2
投票
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" />
© www.soinside.com 2019 - 2024. All rights reserved.