gpt4 book ai didi

schema.org - 混合 JSON-LD CollectionPage 和 Schema.org 的微数据 `hasPart`

转载 作者:行者123 更新时间:2023-12-03 16:52:09 25 4
gpt4 key购买 nike

下面的微数据标记效果很好,Google's structured data testing tool显示一个 CollectionPageWebSite/WebPage作为 child 。

<body itemscope itemtype="https://schema.org/CollectionPage">
<span itemscope itemtype="https://schema.org/WebSite" itemprop="hasPart">
<a href="https://springfield-xxxx.us" itemprop="url">Official site of Springfield</a>
</span>
<span itemscope itemtype="https://schema.org/WebPage" itemprop="hasPart">
<a href="https://facebook.com/group/XXXX" itemprop="url">Local events in Springfield</a>
</span>
<span itemscope itemtype="https://schema.org/WebPage" itemprop="hasPart">
<a href="https://news.us/city/springfield-xxxx" itemprop="url">Latest news in Springfield</a>
</span>
</body>

但是,当我添加 JSON-LD Google's structured data testing tool显示对象 CollectionPageWebPage/WebSite分开,就像他们没有联系一样。这是一个带有 JSON-LD 的示例:

<!DOCTYPE html>
<html>
<head>
<script type="application/ld+json">
{
"description": "...",
"author": {"@type":"Person", "name": "Homer J. Simpson"},
"@type": "CollectionPage",
"url": "http://my-springfield.us/sites",
"publisher": {
"@type": "Organization",
"logo": "Object of type ImageObject here",
"name": "Homer J. Simpson"
},
"image": "...",
"headline": "Springfield Sites",
"sameAs": ["..."],
"@context": "http://schema.org"
}
</script>
</head>
<body>
<span itemscope itemtype="https://schema.org/WebSite" itemprop="hasPart">
<a href="https://springfield-xxxx.us" itemprop="url">Official site of Springfield</a>
</span>
<span itemscope itemtype="https://schema.org/WebPage" itemprop="hasPart">
<a href="https://facebook.com/group/XXXX" itemprop="url">Local events in Springfield</a>
</span>
<span itemscope itemtype="https://schema.org/WebPage" itemprop="hasPart">
<a href="https://news.us/city/springfield-xxxx" itemprop="url">Latest news in Springfield</a>
</span>
</body>
</html>

我试过把 @id在 JSON-LD 和 itemid 中在 body无济于事:Google 测试工具显示两个单独的 CollectionPages 或两个单独的其他类型的项目。

我的问题 : 如何连接JSON-LD和微数据,让谷歌测试工具显示一个 CollectionPageWebPage/WebSite作为 child / Prop ?

最佳答案

like if they had no connection



好吧,它们在您的示例中没有连接。 JSON-LD 和 Microdata 不能在语法级别上协同工作。

如果要连接以不同语法定义的实体,唯一的方法是
  • 给这些实体 URI(如果它们是相同的,则为相同的 URI),以及
  • 将这些 URI 引用为属性值(如果一个实体是另一个实体的属性值)。

  • Giving entities URIs按照您提到的方式工作:使用 @id在 JSON-LD 中,并带有 itemid在微数据中(以及在 RDFa Lite 中使用 resource)。

    消费者(搜索引擎或 Google 的 SDTT 等服务,浏览器插件等本地客户端等)必须支持以下引用(并非全部都支持),如果他们确实支持以下引用,则还必须支持解析附加语法(并非所有人都这样做)。

    但即使您使用此类 URI 引用,它也不会更改您使用的语法的一致性要求。您的 HTML 文档无效,因为您有 itemprop不属于 itemscope 的属性.这是不允许的。因此,如果您想继续使用微数据,您也必须在微数据中提供父项(在您的情况下为 CollectionPage)。

    这将是传达 CollectionPage 的方式出现表示相同的实体(它们具有相同的 URI = 当前文档的基本 URL):
    <script type="application/ld+json">
    {
    "@context": "http://schema.org",
    "@type": "CollectionPage",
    "@id": ""
    }
    </script>

    <div itemscope itemtype="http://schema.org/CollectionPage" itemid="">
    <span itemprop="hasPart" itemscope itemtype="http://schema.org/WebSite"></span>
    <span itemprop="hasPart" itemscope itemtype="http://schema.org/WebSite"></span>
    <span itemprop="hasPart" itemscope itemtype="http://schema.org/WebPage"></span>
    </div>

    谷歌的 SDTT 仍然显示两个 CollectionPage条目( if syntaxes are mixed ),但它们(正确地)具有相同的 URI。由 Google 决定如何处理这些信息以用于其各种结构化数据功能。也许没有/部分/所有功能支持混合语法引用( they don’t seem to document it );他们的 SDTT 如何显示事物并不一定反射(reflect)他们如何对其特征进行解释。

    更多例子
  • same Product in JSON-LD + Microdata
  • WebPage (JSON-LD) + BreadcrumbList (Microdata)
  • Organization (JSON-LD) + WebPage (Microdata)
  • CollegeOrUniversity (JSON-LD) + WebPage (Microdata)
  • 关于schema.org - 混合 JSON-LD CollectionPage 和 Schema.org 的微数据 `hasPart`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50667838/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com