单个页面上有多个 FAQPage 精选片段

Multiple FAQPage featured snippet on a single page

我们想使用 JSON-LD 格式以 FAQPage 的形式添加特色片段。使用 Google 页面上概述的 FAQPage 上的 "See Markup" link,我们能够在下面获得示例特色片段。这似乎暗示该页面的所有问题都应该在一个 <script> 标记中。

我们 运行 通过 Google's Structured Data Testing Tool and Rich 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>

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

A Frequently Asked Question (FAQ) page contains a list of questions and answers pertaining to a particular topic.

Only use FAQPage if your page has a list of questions with answers.

本指南中还有以下示例:

{
  "@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 指南。

您可以使用尽可能多的 script 个元素 ,但您需要表明 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>

无需在每个 script 元素中重复 FAQPage,您可以只定义一次并引用每个问题(通过其 @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>

(您也许可以使用 mainEntityOfPage instead, if you don’t want to list all questions from within the FAQPage. Google’s documentation doesn’t mention it, though. Another alternative is to use 。)


您没有解释为什么要使用多个 script 元素。如果您使用一个 script 元素,但使用多个 top-level 项 ()。

,也许它适用于您的情况

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

您不应该使用多个,因为这可能不适用于每种情况,并且 Google 因此不会总是按预期在 SERP 中显示您的常见问题解答。