我需要将Open Graph标签添加到博客页面。似乎从阅读规范(http://ogp.me/)使用og:type
article
是要走的路。但是,我发现规范不清楚,我不确定如何正确实现语法。
两个示例网站以不同方式实现此示例:
<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="...">
请注意,og
和article
名称空间已注册,og
和article
用作属性。<head>
<meta property="og:title" content="...">
<meta property="og:type" content="article">
<meta property="og:article:author" content="...">
注意没有命名空间注册,og
和og:article
用作属性。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,虽然这有效,但我想知道确切正确的语法是什么?
看看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' />
这是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" />
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" />