混合使用JSON-LD和Microdata Schema.org

Sim*_*mon 6 html5 microdata schema.org json-ld

如果我有以下标记:

<body itemscope="" itemtype="http://schema.org/WebPage">
  <h1 itemprop="name">Lecture 12: Graphs, networks, incidence matrices</h1>
  <p itemprop="description">These video lectures of Professor Gilbert
    Strang teaching 18.06 were  recorded in Fall 1999 and do not
    correspond precisely to the current  edition of the textbook.</p>
  <div itemprop="publisher" itemscope="" itemtype="http://schema.org/CollegeOrUniversity">
    <h4 class="footer">About <span itemprop="name">MIT OpenCourseWare</span></h4>
  </div>
  <a itemprop="license"
    rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/deed.en_US"><img
    src="/images/cc_by-nc-sa.png" alt="Creative Commons logo with terms BY-NC-SA." /></a>
</body>
Run Code Online (Sandbox Code Playgroud)

我想重构发布者属性,因为它很复杂,我不想显示它并执行此操作:

<body itemscope="" itemtype="http://schema.org/WebPage">
  <h1 itemprop="name">Lecture 12: Graphs, networks, incidence matrices</h1>
  <p itemprop="description">These video lectures of Professor Gilbert
    Strang teaching 18.06 were  recorded in Fall 1999 and do not
    correspond precisely to the current  edition of the textbook.</p>
  <script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "CollegeOrUniversity",
        "name": "MIT OpenCourseWare"
    }
</script>
  <a itemprop="license"
    rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/deed.en_US"><img
    src="/images/cc_by-nc-sa.png" alt="Creative Commons logo with terms BY-NC-SA." /></a>
</body>
Run Code Online (Sandbox Code Playgroud)

怎么说<script>这块与itemprop="publisher"物业有关?

我想这两个选项是i).向itemprop脚本标记添加属性或ii).添加一个@attribute代替itempropJSON-LD块.

我也找不到任何文档.有人知道答案吗?

uno*_*nor 2

这是不可能的。如果您在元素上使用该itemprop属性script,则属性值将是textContentscript。这本质上类似于itemprop="{ "@context": "http://schema.org", "@type": "CollegeOrUniversity", "name": "MIT OpenCourseWare" }",因此该值是纯文本,而不是 JSON-LD(并且不解释为 JSON-LD)。

\n\n

如果您不\xe2\x80\x99 不想让发布者名称在页面上可见,您可以使用以下meta元素:

\n\n
<div itemprop="publisher" itemscope itemtype="http://schema.org/CollegeOrUniversity">\n  <meta itemprop="name" content="MIT OpenCourseWare" />\n</div>\n
Run Code Online (Sandbox Code Playgroud)\n\n

也可以使用JSON-LD 节点的节点标识符 ( @id)并在 Microdata 中引用此 URI,但有些使用者可能不支持它(有些可能根本不遵循引用,有些可能只能识别 Schema.org 期望的内容)对于publisher属性:Organization/ Person,但不是 URL):

\n\n
<script type="application/ld+json">\n{\n    "@context": "http://schema.org",\n    "@type": "CollegeOrUniversity",\n    "@id": "http://example.com/mit-opencourseware#thing",\n    "name": "MIT OpenCourseWare"\n}\n</script>\n
Run Code Online (Sandbox Code Playgroud)\n\n
<link itemprop="publisher" href="http://example.com/mit-opencourseware#thing" />\n
Run Code Online (Sandbox Code Playgroud)\n