Error in SDTT: “SiteNavigationElement is not a known valid target type for the additionalType property.”

…衆ロ難τιáo~ 提交于 2019-12-12 06:45:36

问题


I tried a simple example, but the SiteNavigationElement is not working when I test it using the Google Structured Data Testing Tool. It gives the error:

SiteNavigationElement is not a known valid target type for the additionalType property.

The Microdata:

<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>

回答1:


The additionalType property should not be used to create another item (which you are doing with itemscope+itemtype). Its job is to provide the URI of additional types, so the URI itself is the value here.

It seems that you want to mark up each link in your navigation. This is not possible with SiteNavigationElement (it can only be used to mark up the whole navigation, so it’s typically useless).

It would be possible with ItemList, and you could provide SiteNavigationElement as additionalType (but I wouldn’t expect any consumer to make use of this):

<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>

Or as an actual MTE (without 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:


Same as the MTE example above by @unor, except in JSON-LD. (If your list has id's it makes sense to use them.)

<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>


来源:https://stackoverflow.com/questions/45375187/error-in-sdtt-sitenavigationelement-is-not-a-known-valid-target-type-for-the-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!