Stu*_*ong 57 seo html5 schema.org json-ld
我很好奇将JSON-LD应用到schema.org网站的最佳实践.
如果我有一个页面,Article我也想WebSite在我的页面上定义,我会这样:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "http://www.example.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.example.com/search?&q={query}",
"query-input": "required"
}
}
</script>
<!- … -->
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"author": "John Doe",
"interactionCount": [
"UserTweets:1203",
"UserComments:78"
],
"name": "How to Tie a Reef Knot"
}
</script>
Run Code Online (Sandbox Code Playgroud)
这是对还是错?是否有任何好处或需要将它们合并到相同的脚本或项目数组中?
tea*_*ris 51
除了有关如何在网站中存储和管理架构数据的限制之外,拥有单个或多个数据块没有任何好处.
例如,如果您网站中的不同组件负责独立生成每个数据块,则可能需要将它们分开.或者,如果您的网站能够在一个位置管理一个页面的所有模式,则管理单个数据块并将其作为单个script元素呈现可能更简单.
您可以将每个模式列为一个数组,将它们组合成一个脚本:
<script type="application/ld+json">
[
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "http://www.example.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.example.com/search?&q={query}",
"query-input": "required"
}
},
{
"@context": "http://schema.org",
"@type": "Article",
"author": "John Doe",
"interactionCount": [
"UserTweets:1203",
"UserComments:78"
],
"name": "How to Tie a Reef Knot"
}
]
</script>
Run Code Online (Sandbox Code Playgroud)
uno*_*nor 44
这是有效的.您可以根据需要拥有尽可能多的数据块(= script元素).
仅使用一个script元素的一个可能的好处:它允许更容易地使多个项目之间的关系(例如,如果您决定使用hasPart或mainEntity),因为您只需要嵌套项目.
但是,当使用单独的数据块时,通过引用项目的URI @id(感谢@ Gregg Kellogg),当然也可以建立这些关系.
(作为参考,在一个单一的添加两种以上顶级项目script是可能的@graph.)
| 归档时间: |
|
| 查看次数: |
19794 次 |
| 最近记录: |