schema.org可见元素中的结构化数据

时间:2017-11-21 15:46:51

标签: schema.org json-ld structured-data

下面的两个代码片段对用户都是不可见的,但在GSDTT中解析得很好。

 <div>
      <div itemtype="http://schema.org/WebPage" itemscope>
        <div itemprop="mainEntity" itemtype="http://schema.org/Book" itemscope>
          <meta itemprop="datePublished" content="2001-01-15" />
          <meta itemprop="bookFormat" content="http://schema.org/Paperback" />
          <link itemprop="image" href="http://rdf-translator.appspot.com/plato-cover.jpg" />
          <meta itemprop="author" content="Plato" />
          <meta itemprop="numberOfPages" content="224" />
          <meta itemprop="inLanguage" content="English" />
          <div itemprop="review" itemtype="http://schema.org/Review" itemscope>
            <meta itemprop="name" content="Old is new again" />
            <meta itemprop="reviewBody" content="A lovely read." />
            <meta itemprop="author" content="O. Talp" />
            <meta itemprop="datePublished" content="2001-01-16" />
          </div>
        </div>
      </div>

<script type="application/ld+json">
  {
      "@context": "http://schema.org",
      "@type": "WebPage",
      "mainEntity":{
              "@type": "Book",
              "author": "Plato",
              "bookFormat": "http://schema.org/Paperback",
              "datePublished": "2001-01-15",
              "image": "plato-cover.jpg",
              "inLanguage": "English",
              "numberOfPages": "224",
              "review": [
                {
                  "@type": "Review",
                  "author": "John Doe",
                  "datePublished": "2001-01-16",
                  "name": "O. Talp",
                  "reviewBody": "A lovely read."
                }
              ]
            }
    }
</script>

现在考虑下面的代码,其中包含对用户也很敏感的结构化数据;它在GSDTT中解析得很好:

<div itemtype="http://schema.org/WebPage" itemscope>
        <div itemprop="mainEntity" itemtype="http://schema.org/Book" itemscope>
            <p itemprop="datePublished" content="2001-01-15">Published: 2001-01-15  </p>
            <p itemprop="bookFormat" content="http://schema.org/Paperback" />Format: Paperback </p>
            <img itemprop="image" src="https://nl.wikipedia.org/wiki/Plato#/media/File:Plato_Pio-Clemetino_Inv305.jpg" >
            <p itemprop="author" content="Plato" >Author: Plato</p>
            <p itemprop="numberOfPages" content="224" >Pages: 224</p>
            <p itemprop="inLanguage" content="English" >Language: English</p>
            <div itemprop="review" itemtype="http://schema.org/Review" itemscope>
                <p><strong>Review</strong></p>
                <p itemprop="name" content="Old is new again" >Old is nieuw again</p>
                <p itemprop="reviewBody" content="A lovely read.">A lovely read.</p>
                <p itemprop="author" content="O. Talp">Author: O. Talp</p>
                <p itemprop="datePublished" content="2001-01-16">Published: 2001-01-16</p>
            </div>
        </div>
</div>

我更喜欢最后一个代码片段,因为它包含结构化数据产生可见输出。然而微观数据似乎已被弃用,或迟早会被弃用。生成对用户也可见的结构化HTML数据的最佳做法是什么?

1 个答案:

答案 0 :(得分:1)

不推荐使用微数据。

每种语法都有其优点和缺点(JSON-LD vs. Microdata vs. RDFa)。

如果要标记现有内容(而不是复制内容),则必须使用Microdata或RDFa。任何一个都应该适合您的情况(Microdata vs. RDFa)。