【问题标题】:Error in SDTT: "SiteNavigationElement is not a known valid target type for the additionalType property."SDTT 中的错误:“SiteNavigationElement 不是 AdditionalType 属性的已知有效目标类型。”
【发布时间】:2017-07-28 13:48:11
【问题描述】:

我尝试了一个简单的示例,但是当我使用Google Structured Data Testing Tool 对其进行测试时,SiteNavigationElement 无法正常工作。它给出了错误:

SiteNavigationElement 不是 additionalType 属性的已知有效目标类型。

微数据:

<div itemscope itemtype="http://schema.org/WebPageElement">
  <link itemprop="additionalType" href="http://schema.org/ItemList" />
  <meta itemprop="name" content="navigation_menu" />
  <ul>

    <li itemprop="additionalType" itemscope itemtype="http://www.schema.org/SiteNavigationElement">
      <span itemprop="itemListElement">
        <a href="http://www.example.com/link_1" itemprop="url">
          <span itemprop="name">Link 1</span>
        </a>
      </span>
    </li>

    <li itemprop="additionalType" itemscope itemtype="http://www.schema.org/SiteNavigationElement">
      <span itemprop="itemListElement">
        <a href="http://www.example.com/link_2" itemprop="url">
          <span itemprop="name">Link 2</span>
        </a>
      </span>
    </li>

  </ul>
</div>

【问题讨论】:

    标签: schema.org microdata


    【解决方案1】:

    additionalType 属性不应用于创建另一个项目(您正在使用 itemscope+itemtype 执行此操作)。它的工作是提供附加类型的 URI,所以 URI 本身就是这里的值。

    您似乎想标记导航中的每个链接。这对于SiteNavigationElement 是不可能的(它是can only be used to mark up the whole navigation,所以它是typically useless)。

    ItemList 是可能的,您可以将SiteNavigationElement 提供为additionalType(但我不希望任何消费者使用它):

    <div itemscope itemtype="http://schema.org/ItemList">
      <link itemprop="additionalType" href="http://schema.org/SiteNavigationElement" />
      <ul>
        <li itemprop="itemListElement" itemscope itemtype="http://schema.org/WebPage">
          <a href="/link-1" itemprop="url"><span itemprop="name">Link 1</span></a>
        </li>
        <li itemprop="itemListElement" itemscope itemtype="http://schema.org/WebPage">
          <a href="/link-2" itemprop="url"><span itemprop="name">Link 2</span></a>
        </li>
      </ul>
    </div>
    

    或者作为一个实际的 MTE(没有additionalType):

    <div itemscope itemtype="http://schema.org/ItemList http://schema.org/SiteNavigationElement">
      <ul>
        <li itemprop="itemListElement" itemscope itemtype="http://schema.org/WebPage">
          <a href="/link-1" itemprop="url"><span itemprop="name">Link 1</span></a>
        </li>
        <li itemprop="itemListElement" itemscope itemtype="http://schema.org/WebPage">
          <a href="/link-2" itemprop="url"><span itemprop="name">Link 2</span></a>
        </li>
      </ul>
    </div>
    

    【讨论】:

      【解决方案2】:

      与上面 @unor 的 MTE 示例相同,但 JSON-LD 除外。 (如果您的列表有 id,那么使用它们是有意义的。)

      <script type="application/ld+json">
      {
        "@context":"http://schema.org",
        "@type":["ItemList", "SiteNavigationElement"],
        "@id": "https://example.com/#nav",
        "url":"https://example.com/#nav",
        "itemListElement":[
          {
            "@type":"WebPage",
            "position":1,
            "name": "home",
            "@id": "https://example.com/#home",
            "url":"https://example.com/home.html"
          },
          {
            "@type":"WebPage",
            "position":2,
            "name": "Core Solutions",
            "@id": "https://example.com/#core",
            "url":"https://example.com/core.html"
          }
        ]
      }
      </script>
      

      【讨论】:

        猜你喜欢
        • 2018-12-15
        • 2021-05-08
        • 1970-01-01
        • 1970-01-01
        • 2011-11-06
        • 1970-01-01
        • 1970-01-01
        • 2011-04-01
        • 1970-01-01
        相关资源
        最近更新 更多