【问题标题】:How to represent sections of an article with Schema.org in JSON-LD?如何用 JSON-LD 中的 Schema.org 表示文章的各个部分?
【发布时间】:2018-03-13 05:25:47
【问题描述】:

我是 JSON-LD 的新手,即使经过几个小时的搜索,我仍然无法找到一些问题的明确答案。

我的网站类似于 Wikipedia:它提供有关特定主题的大量信息,包括许多较小的部分、较长的页面等。 页面结构的简单示例:

<article id="animals">
  <header>
    <h1> 1. Animals </h1>
  </header>
  <section id="cats">
    <h2> 1.1 Cats </h2>
    <p> Some information about cats </p>
  </section>
  <section id="dogs">
    <h2> 1.2 Dogs </h2>
    <p> Some information about dogs </p>
  </section>
</article>

我想使用 JSON-LD 标记每个部分。 以下是我的做法(把不必要的属性放在一边):

<script type="application/ld+json">
            {
             "@context": "http://schema.org",
             "@graph": [
            {
              "@type": "CreativeWork",
              "@id": "http://www.example.com/example/#animals",
              "name": "Animals",
              "headline": "Animals",
              "genre": "http://vocab.getty.edu/aat/300048715",
              "url": "http://www.example.com/example/#animals"
            },
            {
              "@type": "CreativeWork",
              "@id": "http://www.example.com/example/#cats",
              "name": "Cats",
              "headline": "Cats",
              "genre": "http://vocab.getty.edu/aat/300048715",
              "url": "http://www.example.com/example/#cats",
              "isPartOf": {
                "@type": "CreativeWork",
                "@id": "http://www.example.com/example/#animals"
              }
            }
             ]
            }
        </script>

1) 经过数小时的搜索,我还没有真正找到这些部分应该是什么类型。 CreativeWork 适合使用吗? genre 属性使用是否正确?

2) 如何指定节的位置?是否使用url 属性完成?是否可以像本例那样通过指明该部分的id 来完成?

3) 我还注意到,如果像这样标记一个长页面,脚本会变得非常大。应该是这样的吗?

【问题讨论】:

    标签: schema.org json-ld


    【解决方案1】:

    Schema.org 不提供节/章的类型。如果你想指定每个部分的数据,你应该使用CreativeWork类型,因为这是这种情况下最具体的类型。

    在这些部分使用genre 可能有意义,但我认为http://vocab.getty.edu/aat/300048715 不合适。我不熟悉这个词汇,也找不到明确的定义,但至少术语的标题“文章”表明它不适合文章的部分

    url 属性使用带有片段标识符的URL 非常好,并且对文章的各个部分这样做是有意义的。

    在您的情况下,整个事情可能是Article(或其子类型之一),hasPart/isPartOf 可用于将ArticleCreativeWork 项目链接。

    {
      "@type": "Article",
      "@id": "http://www.example.com/example/#animals",
      "url": "http://www.example.com/example/#animals",
      "name": "Animals",
      "hasPart": [
        {
          "@type": "CreativeWork",
          "@id": "http://www.example.com/example/#cats",
          "url": "http://www.example.com/example/#cats",
          "name": "Cats"
        },
        {
          "@type": "CreativeWork",
          "@id": "http://www.example.com/example/#dogs",
          "url": "http://www.example.com/example/#dogs".
          "name": "Dogs"
        }
      ]
    }
    

    所有这些都可能导致很长的script,尤其是如果您还想使用articleBody(用于整篇文章,包括其所有部分)和text(用于每个部分),因为您必须将大部分内容复制/三倍。这是使用 JSON-LD 的缺点之一。您可以改用 Microdata 或 RDFa 来避免此问题。 (See a short comparison.)

    【讨论】:

      猜你喜欢
      • 2019-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-25
      • 2019-04-29
      • 2019-06-24
      相关资源
      最近更新 更多