本文介绍了混合JSON-LD和Microdata Schema.org的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有以下标记:

.本质上类似于itemprop="{ "@context": "http://schema.org", "@type": "CollegeOrUniversity", "name": "MIT OpenCourseWare" }",因此该值为纯文本,而不是JSON-LD(并且不解释为JSON-LD).

This is not possible like that. If you use the itemprop attribute on the script element, the property value will be the textContent of script. This would be essentially something like itemprop="{ "@context": "http://schema.org", "@type": "CollegeOrUniversity", "name": "MIT OpenCourseWare" }", so the value is the plain text, not JSON-LD (and not interpreted as JSON-LD).

如果您不想在页面上显示发布者名称,则可以使用meta元素:

If you don’t want to have the publisher name visible on your page, you could use a meta element:

<div itemprop="publisher" itemscope itemtype="http://schema.org/CollegeOrUniversity">
  <meta itemprop="name" content="MIT OpenCourseWare" />
</div>

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

It would also be possible to use a node identifier (@id) for the JSON-LD node and reference this URI in Microdata, but some consumers might not support it (some might not follow references at all, some might only recognize what Schema.org expects for the publisher property: Organization/Person, but not URL):

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

这篇关于混合JSON-LD和Microdata Schema.org的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 06:52