【问题标题】:RDFa OfferCatalog SyntaxRDFa OfferCatalog 语法
【发布时间】:2018-02-11 12:44:11
【问题描述】:

我一直在尝试寻找使用 RDFa 将两个项目链接在一起的最佳方法,特别是将 Person 链接到多个 SoftwareApplication 条目。

我目前在作者页面上这样做的方式是:

<div class="container text-center" vocab="http://schema.org/" typeof="Person">
...
<span property="hasOfferCatalog" typeof="OfferCatalog">
  <meta property="numberOfItems" content="10" />
  <span property="itemListElement" typeof="CreativeWork">
    <meta property="name" content="Project Name" />
    <meta property="url" content="https://www.my-domain.tld/ProjectName/" />
  </span>
...

如上项目实际上是一个SoftwareApplication,并且URL有一个完整的RDFa/Schema.org定义,但是如果我把:

typeof="SoftwareApplication" 

然后,在作者的页面上,可以预期的是,Google 的结构化标记验证器会抛出关于所需值不存在的错误,CreativeWork 不会抛出错误但不太具体。我真的不想在引用项目的任何地方重复整个 SoftwareApplication 元数据,我只想说“去看看这个 URL”。

从作者页面交叉引用 SoftwareApplication 页面的正确/最佳方法是什么?在项目中,反向引用很容易,因为有一个 Author 属性,可以是 Person 类型,只需要名称和 URL 即可。

一旦我知道了正确的 RDFa 引用方式,我就会将标签应用于页面中的内容,而不是使用元标签。

【问题讨论】:

    标签: schema.org rdfa


    【解决方案1】:

    要将项目链接在一起,您需要一个合适的属性。喜欢author(说明哪个PersonSoftwareApplication 的创建者),或者喜欢hasOfferCatalog(说明哪个SoftwareApplication 是由Person 提供的)。

    逆属性

    在大多数情况下,Schema.org 只为一个方向定义其属性。所以只有author,没有authorOf。如果您需要其他方向的属性,you can use RDFa’s rev attribute

    链接而不是重复

    如果您不想重复您的数据(即,只定义一次并链接/引用此定义),您可以提供一个 URL 值。 Schema.org 允许对所有属性进行此操作,即使 URL 未列为预期类型。如果您想follow Semantic Web best practices,请为您的实体 URL (as identifiers) 提供 RDFa 的 resource 属性,并使用这些 URL 作为属性值来引用实体。

    为此,只需使用其中一个链接元素(例如,具有hrefsrc 属性的元素)。

    示例

    author 为例:

    <!-- on the page about the software: /software/5 -->
    
    <div typeof="schema:SoftwareApplication" resource="/software/5#this">
      Author: 
      <a property="schema:author" typeof="schema:Person" href="/persons/alice#i">Alice</a>
    </div>
    
    <!-- on the page about the person: /persons/alice -->
    
    <div typeof="schema:Person" resource="/persons/alice#i">
      Authored by:
      <a rev="schema:author" typeof="schema:SoftwareApplication" href="/software/5#this">Software 5</a>
    </div>
    

    Google 的 SDTT 中的错误

    如果结构化数据测试工具给出关于缺少属性的错误,请注意这并不意味着您的标记有问题。 Schema.org 从不需要属性。

    这只是意味着这些属性是required for getting a certain Google search feature。因此,如果您不想获得该功能(或者如果您无法提供所有必需的属性),请忽略这些错误。

    【讨论】:

      【解决方案2】:

      感谢您的其他回复,我将阅读链接的资源,我还找到了针对我的问题的具体案例的解决方案。

      Google Search Console 在Carousels 上有一个页面,显示您可以使用ListItem(它仅“需要”网址)来填充hasOfferCatalog 属性。例如

      <span property="itemListElement" typeof="ListItem">
        <meta property="position" content="1" />
        <meta property="url" content="https://www.my-domain.tld/ProjectName/" />
      </span>
      

      【讨论】:

        猜你喜欢
        • 2020-05-01
        • 2011-09-08
        • 2017-01-11
        • 1970-01-01
        • 1970-01-01
        • 2018-11-18
        • 2011-02-14
        • 2011-12-17
        • 2015-05-17
        相关资源
        最近更新 更多