为什么图片网址是BlogPosting中图片的无效项类型?

时间:2016-02-18 09:36:55

标签: schema.org microdata

我在网页上有以下项目,我将其定义为Scheme.org Article。详细信息已被禁止,但所有正版URL都有效。

<div itemscope itemtype="http://schema.org/Article" class="large-6 columns related blog">
        <meta itemprop="publisher" content="My Company" />
        <meta itemprop="dateModified" content="February 4, 2016" />
        <meta itemprop="mainEntityOfPage" content="http://example.co.uk/main-page/" />      
        <div>
            <h2 itemprop="headline" class="stretch_this"><a itemprop="url" href='http://example.co.uk/main-page/'>Article title</a></h2>
            <p>Posted by <span itemprop="author">A N Other</span> on <span itemprop="datePublished">February 4, 2016</span></p>
            <img itemprop="image" class="post_preview" alt='Article title' class="hide-for-small" src="http://example.co.uk/wp-content/uploads/2016/02/example-image.jpg" /> 
            <p itemprop="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum&hellip;</p>
        </div>
        <a itemprop="url" href="http://example.co.uk/main-page/" class="button readmore">Read More<span class="icon icon-arrow"></span></a>

</div>

当我通过Google's Structured Data Testing Tool运行时,它会在image上出现以下错误:

  

属性itemtype的值无效。

但根据schema.orgimage应该接受图片对象或网址,并且在其他情况下,例如在定义Person

这是什么?

1 个答案:

答案 0 :(得分:10)

虽然根据schema.org网址有效,但Google只接受图片对象,而您用来验证标记的工具是由Google制作的。

请改为尝试:

<div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
            <img itemprop="image" class="post_preview" alt="Article title" class="hide-for-small" src="http://example.co.uk/wp-content/uploads/2016/02/example-image.jpg" /> 
            <meta itemprop="url" content="http://example.co.uk/wp-content/uploads/2016/02/example-image.jpg">
            <meta itemprop="width" content="800">
    		<meta itemprop="height" content="800">
            </div>

不要忘记指定自己的宽度和高度。您需要具备完整的规格。按照schema.org而忽略googles关于这个主题的指令将会犯这样的错误。此外,他们可以随时改变这些。

看起来您必须向他们提供有关您之前的代码段的更多信息。

您可以随时查看https://developers.google.com/structured-data/rich-snippets/articles?hl=en

同时我可以在发布商标签上找到错误。

尝试将发布商的元标记更改为:

<div itemprop="publisher" itemscope itemtype="https://schema.org/Organization">
    <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
      <img src="http://example.co.uk/logo.jpg"/>
      <meta itemprop="url" content="http://example.co.uk/logo.jpg">
      <meta itemprop="width" content="600">
      <meta itemprop="height" content="60">
    </div>
    <meta itemprop="name" content="Company">
  </div>

所以最后你想得到的最终结果是下面的微观数据:

<div itemscope itemtype="http://schema.org/Article" class="large-6 columns related blog">
        <div itemprop="publisher" itemscope itemtype="https://schema.org/Organization">
    <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
      <img src="http://example.co.uk/logo.jpg"/>
      <meta itemprop="url" content="http://example.co.uk/logo.jpg">
      <meta itemprop="width" content="600">
      <meta itemprop="height" content="60">
    </div>
    <meta itemprop="name" content="Company">
  </div>
        <meta itemprop="dateModified" content="February 4, 2016" />
        <meta itemprop="mainEntityOfPage" content="http://example.co.uk/main-page/" />        
            <h2 itemprop="headline" class="stretch_this"><a itemprop="url" href='http://example.co.uk/main-page/'>Article title</a></h2>
            <p>Posted by <span itemprop="author">A N Other</span> on <span itemprop="datePublished">February 4, 2016</span></p>
            <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
            <img itemprop="image" class="post_preview" alt="Article title" class="hide-for-small" src="http://example.co.uk/wp-content/uploads/2016/02/example-image.jpg" /> 
            <meta itemprop="url" content="http://example.co.uk/wp-content/uploads/2016/02/example-image.jpg">
            <meta itemprop="width" content="800">
    		<meta itemprop="height" content="800">
            </div>
            <p itemprop="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum&hellip;</p>
        
        <a itemprop="url" href="http://example.co.uk/main-page/" class="button readmore">Read More<span class="icon icon-arrow"></span></a>
</div>