ily*_*rov 5 microdata schema.org json-ld
下面的微数据标记效果很好,谷歌的结构化数据测试工具显示了一个CollectionPage和WebSite/WebPage作为孩子。
<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>
Run Code Online (Sandbox Code Playgroud)
但是,当我添加 JSON-LD 时,Google 的结构化数据测试工具会分别显示对象CollectionPage,WebPage/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>
Run Code Online (Sandbox Code Playgroud)
我试图把@id在JSON-LD和itemid对body无济于事:谷歌测试工具显示两个独立的CollectionPages或其他类型的两个独立的项目。
我的问题:如何连接 JSON-LD 和微数据,以便 Google 测试工具显示一个CollectionPagewith WebPage/WebSiteas children/props?
\n\n\n就像他们没有联系一样
\n
嗯,他们是\xe2\x80\x99t连接。JSON-LD 和 Microdata 可以在语法级别上协同工作。
\n\n如果要连接以不同语法定义的实体,唯一的方法是
\n\n提供实体 URI 的工作方式与您提到的方式相同:@id在 JSON-LD 中使用,itemid在 Microdata 中使用(以及resource在 RDFa Lite 中使用)。
消费者(如搜索引擎或 Google\xe2\x80\x99s SDTT 等服务、浏览器插件等本地客户端)必须支持以下引用(并非全部都支持),如果他们确实支持以下引用,他们也将拥有支持解析附加语法(并非全部都支持)。
\n\n但即使您使用此类 URI 引用,它也不会改变您使用的语法的一致性要求。您的 HTML 文档无效,因为您的itemprop属性不\xe2\x80\x99t 属于itemscope. 这是不允许的。因此,如果您想继续使用微数据,您也必须在微数据中提供父项(CollectionPage在您的情况下)。
这是表达两个事件代表同一实体的方式CollectionPage(它们具有相同的 URI = 当前文档的基本 URL):
<script type="application/ld+json">\n {\n "@context": "http://schema.org",\n "@type": "CollectionPage",\n "@id": ""\n }\n</script>\n\n<div itemscope itemtype="http://schema.org/CollectionPage" itemid="">\n <span itemprop="hasPart" itemscope itemtype="http://schema.org/WebSite"></span>\n <span itemprop="hasPart" itemscope itemtype="http://schema.org/WebSite"></span>\n <span itemprop="hasPart" itemscope itemtype="http://schema.org/WebPage"></span>\n</div>\nRun Code Online (Sandbox Code Playgroud)\n\nGoogle\xe2\x80\x99s SDTT 仍然显示两个CollectionPage条目(如果语法混合),但它们(正确地)具有相同的 URI。由 Google 决定如何利用这些信息来实现其各种结构化数据功能。也许它们的所有功能都支持混合语法引用(它们似乎没有记录它);他们的 SDTT 如何显示事物并不一定反映他们如何解释其功能。
ProductJSON-LD + 微数据中相同WebPage(JSON-LD) + BreadcrumbList(微数据)Organization(JSON-LD) + WebPage(微数据)CollegeOrUniversity(JSON-LD) + WebPage(微数据)| 归档时间: |
|
| 查看次数: |
2223 次 |
| 最近记录: |