【问题标题】:Why is an image URL an invalid item type for an image in a BlogPosting?为什么图像 URL 是 BlogPosting 中图像的无效项目类型?
【发布时间】:2016-05-30 09:30:06
【问题描述】:

我在一个网页上有以下项目,我将其定义为 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 应该接受图像对象或 URL,并且在其他情况下具有,例如定义Person时。

这是怎么回事?

【问题讨论】:

    标签: schema.org microdata


    【解决方案1】:

    虽然根据 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 进行操作会导致类似的错误发生。此外,他们可以随时更改。

    看起来你必须向他们提供比以前更多的关于你的 sn-p 的信息。

    更多信息您可以随时查看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>

    【讨论】:

    • 请注意 link(而不是 metamust be used 如果值是 URL,例如,对于 mainEntityOfPage 属性。 ··· 您可以在img 元素上提供itemprop="url",而不是为此目的使用单独的link 元素。
    猜你喜欢
    • 2014-07-11
    • 1970-01-01
    • 1970-01-01
    • 2011-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-20
    相关资源
    最近更新 更多