现在,在网上看了几篇文章后,我终于搞糊涂了。我有一个包含多个子类别的主导航。找到了 2 个例子,然后我就停下来了,因为我很困惑。
示例1:
{
"@context":"http://schema.org",
"@type":"ItemList",
"itemListElement":[
{
"@type": "SiteNavigationElement",
"position": 1,
"name": "Sign Up",
"description": "Create your example profile.",
"url":"https://example.com"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "About us",
"description": "Read more about example company",
"url":"https://example.com/about"
},
{......
示例2:
{
"@context": "https://schema.org",
"@graph":
[
{
"@context": "https://schema.org",
"@type":"SiteNavigationElement",
"@id":"#table-of-contents",
"name": "Section 1",
"url": "https://www.example.com/page#toc-1"
},
{
"@context": "https://schema.org",
"@type":"SiteNavigationElement",
"@id":"#table-of-contents",
"name": "Section 2",
"url": "https://www.example.com/page#toc-2"
},
{....
这两种用法有什么区别?它们都是有效的,但无法决定采用哪一个。
最佳答案
示例 1 由一个 ItemList
和两个 SiteNavigationElement
元素组成。
示例 2 由两个 SiteNavigationElement
元素组成(这两个元素相同,因为它们具有相同的 @id
值)。
我想说这两种都不适合您想要传达的内容。
SiteNavigationElement
类型表示整个导航,而不是单个导航链接 ( most likely )。
{
"@context": "http://schema.org",
"@type": "SiteNavigationElement",
"name": "Main navigation"
}
如果您想提供有关每个导航链接的数据,您可以考虑使用 ItemList
此外,每个链接可以是 WebPage
(用 itemListElement
指定)。
{
"@context":"http://schema.org",
"@type": ["SiteNavigationElement", "ItemList"],
"name": "Main navigation",
"itemListElement": [
{"@type": "WebPage"},
{"@type": "WebPage"},
{"@type": "WebPage"}
]
}
关于navigation - JSON-LD 中 SiteNavigationElement 的正确语法和用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52762018/