提问人:Alex 提问时间:8/30/2023 更新时间:9/3/2023 访问量:63
JSON-LD SiteNavigationElement:子页面的架构无法识别 itemListElement 属性
JSON-LD SiteNavigationElement : itemListElement property was not recognized by the schema for subpages
问:
我有一个问题,我正在尝试使用“SiteNavigationElement”类型方案为我的网页制作 JSON-LD 代码。
但是,当我尝试验证它时。它被拒绝并发出 5 个警告。 这让我感到好奇。因为只要我有一个没有子页面的一级 JSON-LD 代码,它就可以很好地验证。
但是当我添加子页面时,它会生成警告。
从波兰语翻译过来,验证者说:
架构无法识别 itemListElement 属性(例如 schema.org) 作为 SiteNavigationElement 对象的一部分。
我不知道如何解决这个问题。
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SiteNavigationElement",
"name": "Top Level Navigation",
"mainEntity": [
[
{
"@type": "SiteNavigationElement",
"position": 1,
"name": "home",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "A very nice page",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-the-page"
},
{
"@type": "SiteNavigationElement",
"position": 3,
"name": "diensten",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/all-services"
},
{
"@type": "SiteNavigationElement",
"position": 4,
"name": "contact",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact",
"@context": "https://schema.org",
"itemListElement": [
{
"@type": "SiteNavigationElement",
"position": 1,
"name": "Den Haag",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact/den-haag"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "Haarlem",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact/haarlem"
}
]
},
{
"@type": "SiteNavigationElement",
"position": 5,
"name": "over ons",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-us",
"@context": "https://schema.org",
"itemListElement": [
{
"@type": "SiteNavigationElement",
"position": 1,
"name": "A very nice page",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-the-page"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "Where we are good at",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-us/we-are-good-at"
}
]
},
{
"@type": "SiteNavigationElement",
"name": "Who are we and what we are good at",
"description": "TEMP DESCRIPTION",
"@context": "https://schema.org",
"itemListElement": [
{
"@type": "SiteNavigationElement",
"position": 1,
"name": "Alle diensten",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/who-are-we/all-services"
}
]
},
{
"@type": "SiteNavigationElement",
"position": 6,
"name": "A very simple explanation about everthing",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/a-simple-explanation"
},
{
"@type": "SiteNavigationElement",
"position": 7,
"name": "Nikola",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/nikola"
},
{
"@type": "SiteNavigationElement",
"position": 8,
"name": "Contact",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/testcontact"
},
{
"@type": "SiteNavigationElement",
"position": 9,
"name": "Our projects",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/our-projects"
},
{
"@type": "SiteNavigationElement",
"position": 10,
"name": "sddsds",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/this-works-great"
},
{
"@type": "SiteNavigationElement",
"position": 11,
"name": "Building your house",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/building-your-house"
},
{
"@type": "SiteNavigationElement",
"position": 12,
"name": "By bike",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/bike"
}
]
]
}
</script>
基本上,一旦我开始一个子元素,它就会给我一个警告。 但我想知道我在那里做错了什么?
{
"@type": "SiteNavigationElement",
"position": 4,
"name": "contact",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact",
"@context": "https://schema.org",
"itemListElement": [
{
"@type": "SiteNavigationElement",
"position": 1,
"name": "Den Haag",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact/den-haag"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "Haarlem",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact/haarlem"
}
]
},
我确实开始了这个职位。我再次设置了上下文。但同样......没有子页面/子页面,效果很好。
没有子页面且没有警告的工作示例
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SiteNavigationElement",
"name": "Top Level Navigation",
"mainEntity": [
[
{
"@type": "SiteNavigationElement",
"position": 1,
"name": "home",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "A very nice page",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-the-page"
},
{
"@type": "SiteNavigationElement",
"position": 3,
"name": "diensten",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/all-services"
},
{
"@type": "SiteNavigationElement",
"position": 4,
"name": "A test page x 0",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/test-page-x-0"
},
{
"@type": "SiteNavigationElement",
"position": 5,
"name": "A test page x",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/test-page-x"
},
{
"@type": "SiteNavigationElement",
"position": 6,
"name": "A very simple explanation about everthing",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/a-simple-explanation"
},
{
"@type": "SiteNavigationElement",
"position": 7,
"name": "Nikola",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/nikola"
},
{
"@type": "SiteNavigationElement",
"position": 8,
"name": "Contact",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/testcontact"
},
{
"@type": "SiteNavigationElement",
"position": 9,
"name": "Our projects",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/our-projects"
},
{
"@type": "SiteNavigationElement",
"position": 10,
"name": "sddsds",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/this-works-great"
},
{
"@type": "SiteNavigationElement",
"position": 11,
"name": "Building your house",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/building-your-house"
},
{
"@type": "SiteNavigationElement",
"position": 12,
"name": "By bike",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/bike"
}
]
]
}
</script>
答:
基本上,一旦我开始一个子元素,它就会给我一个警告。但 我想知道我在那里做错了什么?
您已在不支持此属性的类型中嵌套了一个子元素,例如该属性。若要解决此问题,请使用可用于 SiteNavigationElement 类型的属性。itemListElement
SiteNavigationElement
如前所述,标记使用实体,该实体没有 Schema.org 中定义的属性(可与 ItemList
一起使用)。SiteNavigationElement
itemListElement
您似乎正在尝试在子父关系中构造多个实体。SiteNavigationElement
有几种方法可以做到这一点。
您可以将 property 替换为 hasPart
,这样可以表示子父关系,并通过验证。itemListElement
"@type": "SiteNavigationElement",
"position": 4,
"name": "contact",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact",
"@context": "https://schema.org",
"hasPart": [
{
"@type": "SiteNavigationElement",
"position": 1,
通过验证的完整代码:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SiteNavigationElement",
"name": "Top Level Navigation",
"mainEntity": [
[{
"@type": "SiteNavigationElement",
"position": 1,
"name": "home",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "A very nice page",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-the-page"
},
{
"@type": "SiteNavigationElement",
"position": 3,
"name": "diensten",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/all-services"
},
{
"@type": "SiteNavigationElement",
"position": 4,
"name": "contact",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact",
"@context": "https://schema.org",
"hasPart": [{
"@type": "SiteNavigationElement",
"position": 1,
"name": "Den Haag",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact/den-haag"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "Haarlem",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact/haarlem"
}
]
},
{
"@type": "SiteNavigationElement",
"position": 5,
"name": "over ons",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-us",
"@context": "https://schema.org",
"hasPart": [{
"@type": "SiteNavigationElement",
"position": 1,
"name": "A very nice page",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-the-page"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "Where we are good at",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-us/we-are-good-at"
}
]
},
{
"@type": "SiteNavigationElement",
"name": "Who are we and what we are good at",
"description": "TEMP DESCRIPTION",
"@context": "https://schema.org",
"hasPart": [{
"@type": "SiteNavigationElement",
"position": 1,
"name": "Alle diensten",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/who-are-we/all-services"
}]
},
{
"@type": "SiteNavigationElement",
"position": 6,
"name": "A very simple explanation about everthing",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/a-simple-explanation"
},
{
"@type": "SiteNavigationElement",
"position": 7,
"name": "Nikola",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/nikola"
},
{
"@type": "SiteNavigationElement",
"position": 8,
"name": "Contact",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/testcontact"
},
{
"@type": "SiteNavigationElement",
"position": 9,
"name": "Our projects",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/our-projects"
},
{
"@type": "SiteNavigationElement",
"position": 10,
"name": "sddsds",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/this-works-great"
},
{
"@type": "SiteNavigationElement",
"position": 11,
"name": "Building your house",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/building-your-house"
},
{
"@type": "SiteNavigationElement",
"position": 12,
"name": "By bike",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/bike"
}
]
]
}
</script>
此外,由于属性属于实体,您可以简单地将其添加到 ,这在语义上意味着它是两个实体,并允许您同时混合两个实体的属性:itemListElement
ItemList
SiteNavigationElement
"@type": ["SiteNavigationElement", "ItemList"],
"position": 4,
"name": "contact",
通过验证的完整代码:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SiteNavigationElement",
"name": "Top Level Navigation",
"mainEntity": [
[{
"@type": "SiteNavigationElement",
"position": 1,
"name": "home",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "A very nice page",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-the-page"
},
{
"@type": "SiteNavigationElement",
"position": 3,
"name": "diensten",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/all-services"
},
{
"@type": ["SiteNavigationElement", "ItemList"],
"position": 4,
"name": "contact",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact",
"@context": "https://schema.org",
"itemListElement": [{
"@type": "SiteNavigationElement",
"position": 1,
"name": "Den Haag",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact/den-haag"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "Haarlem",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/contact/haarlem"
}
]
},
{
"@type": ["SiteNavigationElement", "ItemList"],
"position": 5,
"name": "over ons",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-us",
"@context": "https://schema.org",
"itemListElement": [{
"@type": "SiteNavigationElement",
"position": 1,
"name": "A very nice page",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-the-page"
},
{
"@type": "SiteNavigationElement",
"position": 2,
"name": "Where we are good at",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/about-us/we-are-good-at"
}
]
},
{
"@type": ["SiteNavigationElement", "ItemList"],
"name": "Who are we and what we are good at",
"description": "TEMP DESCRIPTION",
"@context": "https://schema.org",
"itemListElement": [{
"@type": "SiteNavigationElement",
"position": 1,
"name": "Alle diensten",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/who-are-we/all-services"
}]
},
{
"@type": "SiteNavigationElement",
"position": 6,
"name": "A very simple explanation about everthing",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/a-simple-explanation"
},
{
"@type": "SiteNavigationElement",
"position": 7,
"name": "Nikola",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/nikola"
},
{
"@type": "SiteNavigationElement",
"position": 8,
"name": "Contact",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/testcontact"
},
{
"@type": "SiteNavigationElement",
"position": 9,
"name": "Our projects",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/our-projects"
},
{
"@type": "SiteNavigationElement",
"position": 10,
"name": "sddsds",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/this-works-great"
},
{
"@type": "SiteNavigationElement",
"position": 11,
"name": "Building your house",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/building-your-house"
},
{
"@type": "SiteNavigationElement",
"position": 12,
"name": "By bike",
"description": "TEMP DESCRIPTION",
"url": "https://example.com/bike"
}
]
]
}
</script>
它还会模糊两个实体之间的界限,所以我会使用前一种方法。
根据您使用结构化数据的目的,您还可以考虑使用 BreadcrumbList(似乎没有提到子级与父级关系,您只是创建一个页面列表,并且 property 不能与该实体一起使用......hasPart
评论