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

schema.org structured data in visible elements

下面的两个代码片段对用户来说都是不可见的,但在 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 数据的最佳做法是什么?

未弃用微数据。

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

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