最近,我读了很多有关使用schema.org标记结构化数据的信息,第一个问题是,建议完全使用它json-ld
吗?因为它似乎是新的,尚未得到完全支持。我的第二个问题是在主页或存档页面(通常是其中包含一篇以上文章或产品或博客文章的页面)上,我如何使用schema.org?例如这样的页面:
<!DOCTYPE html>
<html>
<head>
<title>Blog Home Page</title>
</head>
<body>
<h1>Blog title</h1>
<!-- this needs schema.org -->
<article>
<h2>Article title</h2>
Writtem by <span>Authorname</span> on <time datetime="">21 april</time>
<p>
Some text
</p>
Rated :
<div class="star-rate">
<span class="star full">
<span class="star full">
<span class="star full">
<span class="star half">
<span class="star empty">
</div>
By <span>5</span> users.
</article>
<article>
<h2>Article title</h2>
Writtem by <span>Authorname</span> on <time datetime="">21 april</time>
<p>
Some text
</p>
Rated :
<div class="star-rate">
<span class="star full">
<span class="star full">
<span class="star full">
<span class="star half">
<span class="star empty">
</div>
By <span>5</span> users.
</article>
<!-- and more articles to go -->
</body>
</html>
我如何使用josn-ld标记结构化数据以及如何将json对象与<article>
标签相关联。
有些使用者支持JSON-LD,有些则不支持。对此没有一个普遍的答案,这取决于您要支持哪些消费者/功能。例如,消费者Google建议将JSON-LD用于某些功能,但不支持其某些其他功能。
如果页面上有多个实体(例如示例中的两篇文章),则只需提供多个节点。有多种方法可以实现此目的:
您可以为每个节点提供一个单独的 script
元素:
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "CreativeWork"
}
</script>
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "CreativeWork"
}
</script>
您可以提供一个script
元素并使用数组作为值@graph
(@context
为所有节点共享):
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@graph":
[
{
"@type": "CreativeWork"
},
{
"@type": "CreativeWork"
}
]
}
</script>
为了允许其他人区分节点(并做出关于它们的声明),可以为每个节点提供一个带有@id
关键字的URI 。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句