我发现新手很难将几个或几个JSON-LD标记合并在一起。你能告诉我我在做什么错吗?
当我在Google结构化数据测试工具中输入以下标记时,它仅显示Organization架构类型的结果,同时也显示架构类型的结果BreadcrumbList。
Organization
BreadcrumbList
<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "Organization", "legalName": "Example INC", "logo": "https://www.example.com/image.png", "url": "https://www.example.com/", "sameAs": [ "https://www.facebook.com/example", "https://www.linkedin.com/company/example", "https://twitter.com/example", "https://www.youtube.com/user/example", "https://en.wikipedia.org/wiki/example" ] } "@type": "BreadcrumbList", "itemListElement": [ { "@type": "ListItem", "position": "1", "item": { "@id": "https://www.example.com/", "name": "Homepage" } } ] </script>
要指定多个顶级项目,您可以使用三个选项:
<script type="application/ld+json"> [ { "@context": "http://schema.org", "@type": "Organization" }, { "@context": "http://schema.org", "@type": "BreadcrumbList" } ] </script>
缺点:您必须@context为每个项目重复此操作。
@context
@graph
<script type="application/ld+json"> { "@context": "http://schema.org", "@graph": [ { "@type": "Organization" }, { "@type": "BreadcrumbList" } ] } </script>
script
<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "Organization" } </script> <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "BreadcrumbList" } </script>
缺点:您必须为每个项目重复script元素和@context。
但是通常最好只提供一个顶级项,并将其他项嵌套在适当的属性下。不过,这并非在所有情况下都可行。
在您的情况下,似乎可以通过添加WebPage项目来实现,假设它是组织的页面,并且此页面具有以下面包屑列表:
WebPage
<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "WebPage", "provider": { "@type": "Organization" }, "breadcrumb": { "@type": "BreadcrumbList" } } </script>
(您可以在不嵌套的情况下实现相同效果:使用,为每个项目提供一个URI @id,然后将这些URI作为属性值引用。)
@id