单个页面上有多个FAQPage特色片段

时间:2019-05-22 19:08:52

标签: html schema.org json-ld google-rich-snippets

我们想使用JSON-LD格式以FAQPage的形式添加特色片段。使用Google页面上概述的FAQPage上的“查看标记”链接,我们可以在下面获取示例精选代码段。这似乎暗示该页面的所有问题都应放在一个<script>标记中。

我们在Google's Structured Data Testing ToolRich Results tool中进行了以下操作,并返回零错误。但是,没有提到将它们全部放在一个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>

变体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>

3 个答案:

答案 0 :(得分:0)

The guide of Google for FAQ Page 告诉我们:

  

“常见问题(FAQ)”页面包含问题的列表   以及与特定主题相关的答案。

     

仅当您的页面上有列表带有答案的问题时,才使用FAQPage。

本指南中还包括以下示例:

{
  "@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": "How long does it take to process a refund?",
    "acceptedAnswer": {
      "@type": "Answer",
      "text": "We will reimburse you for returned items in the same way you paid for them. For example, any amounts deducted from a gift card will be credited back to a gift card. For returns by mail, once we receive your return, we will process it within 4–5 business days. It may take up to 7 days after we process the return to reflect in your account, depending on your financial institution's processing time."
    }
  }, {
    "@type": "Question",
    "name": "What is the policy for late/non-delivery of items ordered online?",
    "acceptedAnswer": {
      "@type": "Answer",
      "text": "Our local teams work diligently to make sure that your order arrives on time, within our normaldelivery hours of 9AM to 8PM in the recipient's time zone. During  busy holiday periods like Christmas, Valentine's and Mother's Day, we may extend our delivery hours before 9AM and after 8PM to ensure that all gifts are delivered on time. If for any reason your gift does not arrive on time, our dedicated Customer Service agents will do everything they can to help successfully resolve your issue. <br/> <p><a href='https://example.com/orders/'>Click here</a> to complete the form with your order-related question(s).</p>"
    }
  }, {
    "@type": "Question",
    "name": "When will my credit card be charged?",
    "acceptedAnswer": {
      "@type": "Answer",
      "text": "We'll attempt to securely charge your credit card at the point of purchase online. If there's a problem, you'll be notified on the spot and prompted to use another card. Once we receive verification of sufficient funds, your payment will be completed and transferred securely to us. Your account will be charged in 24 to 48 hours."
    }
  }, {
    "@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>"}
    }]
  }

因此,您的问题的答案可能是:使用您指定的第一个选项,并使您的数据完全符合指定的Google指南。

答案 1 :(得分:0)

您可以使用多达script个元素as you want,但需要说明FAQPage项是相同的。为此,您可以给他们提供相同的URI(在@id中)。

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "@id": "/faq",
  "mainEntity": {
    "@type": "Question",
    "name": "What is the return policy?"
  }
}
</script>

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "@id": "/faq",
  "mainEntity": {
    "@type": "Question",
    "name": "Will I be charged sales tax for online orders?"
  }
}
</script>

除了在每个FAQPage元素中重复script之外,您只能定义一次并引用每个问题(通过其@id):

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "@id": "/faq",
  "mainEntity": [
    {"@id": "/faq#1"},
    {"@id": "/faq#2"}
  ]
}
</script>

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Question",
  "@id": "/faq#1",
  "name": "What is the return policy?"
}
</script>

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Question",
  "@id": "/faq#2",
  "name": "Will I be charged sales tax for online orders?"
}
</script>

((如果您不想在FAQPage中列出所有问题,则可以使用mainEntityOfPage。不过Google的文档中没有提及它。另一种选择是使用@reverse。)


您没有解释为什么要使用多个script元素。如果您使用一个script元素,但包含多个顶级项目(using @graph),则可能对您的情况有用。

答案 2 :(得分:-1)

请在此处找到有效且可验证的代码解决方案:https://gist.github.com/dmnkhrn/ea0244119163e255a4e5a6f3ed553d89

您不应使用多个,因为这可能无法在每种情况下都起作用,因此Google不会总是按预期在SERP中显示您的常见问题解答。