use*_*abc 1 html schema.org json-ld google-rich-snippets
我们希望使用 JSON-LD 格式以FAQPage的形式添加特色片段。使用 Google 页面概述上的“查看标记”链接FAQPage,我们可以获得下面的示例特色片段。这似乎意味着该页面的所有问题都应该在一个<script>标签中。
我们通过Google 的结构化数据测试工具和丰富结果工具运行了以下内容,它返回了零错误。然而,没有提到它全部在一个script标签中。
如果我们要使用FAQPage特色片段,我们需要使用的正确变体是什么(1 或 2)?
变体 1 - 将所有问题集中在一个script标签中:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [{
"@type": "Question",
"name": "What is the return policy?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Most unopened items in new condition and returned within <strong>90 days</strong> will receive a refund or exchange. Some items have a modified return policy noted on the receipt or packing slip. Items that are opened or damaged or do not have a receipt may be denied a refund or exchange. Items purchased online or in-store may be returned to any store.<br /><p>Online purchases may be returned via a major parcel carrier. <a href='http://example.com/returns'> Click here </a> to initiate a return.</p>"
}
}, {
"@type": "Question",
"name": "Will I be charged sales tax for online orders?",
"acceptedAnswer": {
"@type": "Answer",
"text":"Local and State sales tax will be collected if your recipient's mailing address is in: <ul><li>Arizona</li><li>California</li><li>Colorado</li></ul>"}
}]
}
</script>
Run Code Online (Sandbox Code Playgroud)
变体 2 - 每个问题都分为不同的script标签:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": {
"@type": "Question",
"name": "What is the return policy?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Most unopened items in new condition and returned within <strong>90 days</strong> will receive a refund or exchange. Some items have a modified return policy noted on the receipt or packing slip. Items that are opened or damaged or do not have a receipt may be denied a refund or exchange. Items purchased online or in-store may be returned to any store.<br /><p>Online purchases may be returned via a major parcel carrier. <a href='http://example.com/returns'> Click here </a> to initiate a return.</p>"
}
}
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": {
"@type": "Question",
"name": "Will I be charged sales tax for online orders?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Local and State sales tax will be collected if your recipient's mailing address is in: <ul><li>Arizona</li><li>California</li><li>Colorado</li></ul>"
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
您可以使用任意script数量的元素,但您需要传达这些项目是相同的。您可以通过为它们提供相同的 URI(在 中)来完成此操作。FAQPage@id
<script type="application/ld+json">\n{\n "@context": "https://schema.org",\n "@type": "FAQPage",\n "@id": "/faq",\n "mainEntity": {\n "@type": "Question",\n "name": "What is the return policy?"\n }\n}\n</script>\n\n<script type="application/ld+json">\n{\n "@context": "https://schema.org",\n "@type": "FAQPage",\n "@id": "/faq",\n "mainEntity": {\n "@type": "Question",\n "name": "Will I be charged sales tax for online orders?"\n }\n}\n</script>\nRun Code Online (Sandbox Code Playgroud)\n\n您可以只定义一次并引用每个问题(通过其) ,而不是FAQPage在每个元素中重复:script@id
<script type="application/ld+json">\n{\n "@context": "https://schema.org",\n "@type": "FAQPage",\n "@id": "/faq",\n "mainEntity": [\n {"@id": "/faq#1"},\n {"@id": "/faq#2"}\n ]\n}\n</script>\n\n<script type="application/ld+json">\n{\n "@context": "https://schema.org",\n "@type": "Question",\n "@id": "/faq#1",\n "name": "What is the return policy?"\n}\n</script>\n\n<script type="application/ld+json">\n{\n "@context": "https://schema.org",\n "@type": "Question",\n "@id": "/faq#2",\n "name": "Will I be charged sales tax for online orders?"\n}\n</script>\nRun Code Online (Sandbox Code Playgroud)\n\nmainEntityOfPage(如果您不想列出FAQPage.Google\xe2\x80\x99s 文档中的所有问题,那么您也许可以使用它。不过,另一种选择是使用@reverse。)
您没有解释为什么要使用多个script元素。script如果您使用一个元素,但具有多个顶级项目(using@graph ) ,也许它适合您的情况。