谷歌的事件片段在富结果测试中只显示一个事件

问题描述

我想使用 Event Snippet for Google 在 Google 上显示我的事件,我发现的所有示例仅在显示一个事件时显示示例,而我在代码段上显示多个事件。

下面的示例代码不是真实数据,但我正在测试以了解如何实现多个事件

  • 奇拉和莫里森历险记第一期
  • 奇拉和莫里森历险记事件二
  • 奇拉和莫里森历险记事件三

当我测试它时,下面的代码通过了 HERE 但只显示一个事件,而它应该显示所有事件

enter image description here

以下是使用 Javascript json+ld 格式的 Snippet 代码,如果有人能帮我解决这个问题,我将不胜感激,以便它显示所有三个事件

<html>
  <head>
    <title>The Adventures of Kira and Morrison</title>
    <script type="application/ld+json">
    {
      "@context": "https://schema.org","@type": "Event","name": "The Adventures of Kira and Morrison EVENT ONE","startDate": "2025-07-21T19:00-05:00","endDate": "2025-07-21T23:00-05:00","eventStatus": "https://schema.org/EventCancelled","eventAttendanceMode": "https://schema.org/OfflineEventAttendanceMode","location": {
        "@type": "Place","name": "Snickerpark Stadium","address": {
          "@type": "PostalAddress","streetAddress": "100 West Snickerpark Dr","addressLocality": "Snickertown","postalCode": "19019","addressRegion": "PA","addressCountry": "US"
        }
      },"image": [
        "https://example.com/photos/1x1/photo.jpg","https://example.com/photos/4x3/photo.jpg","https://example.com/photos/16x9/photo.jpg"
       ],"description": "The Adventures of Kira and Morrison is coming to Snickertown in a can't miss performance.","offers": {
        "@type": "Offer","url": "https://www.example.com/event_offer/12345_201803180430","price": "30","priceCurrency": "USD","availability": "https://schema.org/InStock","validFrom": "2024-05-21T12:00"
      },"performer": {
        "@type": "PerformingGroup","name": "Kira and Morrison"
      },"organizer": {
        "@type": "Organization","name": "Kira and Morrison Music","url": "https://kiraandmorrisonmusic.com"
      }
    },{
      "@context": "https://schema.org","name": "The Adventures of Kira and Morrison EVENT TWO","startDate": "2025-08-21T19:00-05:00","endDate": "2025-08-21T23:00-05:00","name": "The Adventures of Kira and Morrison EVENT THREE","startDate": "2025-09-21T19:00-05:00","endDate": "2025-09-21T23:00-05:00","url": "https://kiraandmorrisonmusic.com"
      }
    }
    </script>
  </head>
  <body>
  </body>
</html>

解决方法

我找到了实际上很简单的解决方案,但有时有些事情很难解决,因为我无法在互联网上找到有关此的参考,几乎所有我看到的示例都在他们的示例中显示了 1 个事件..

>

多个事件被包装在方括号 [] 中,只有这样它们才能正确显示。

下面的代码工作正常,但在我的实际代码中,很少出现可选参数的警告,这是由于与此事件无关的可选参数(例如 offer,performer)。

<html>
      <head>
        <title>The Adventures of Kira and Morrison</title>
        <script type="application/ld+json">
        [{
          "@context": "https://schema.org","@type": "Event","name": "The Adventures of Kira and Morrison EVENT ONE","startDate": "2025-07-21T19:00-05:00","endDate": "2025-07-21T23:00-05:00","eventStatus": "https://schema.org/EventCancelled","eventAttendanceMode": "https://schema.org/OfflineEventAttendanceMode","location": {
            "@type": "Place","name": "Snickerpark Stadium","address": {
              "@type": "PostalAddress","streetAddress": "100 West Snickerpark Dr","addressLocality": "Snickertown","postalCode": "19019","addressRegion": "PA","addressCountry": "US"
            }
          },"image": [
            "https://example.com/photos/1x1/photo.jpg","https://example.com/photos/4x3/photo.jpg","https://example.com/photos/16x9/photo.jpg"
           ],"description": "The Adventures of Kira and Morrison is coming to Snickertown in a can't miss performance.","offers": {
            "@type": "Offer","url": "https://www.example.com/event_offer/12345_201803180430","price": "30","priceCurrency": "USD","availability": "https://schema.org/InStock","validFrom": "2024-05-21T12:00"
          },"performer": {
            "@type": "PerformingGroup","name": "Kira and Morrison"
          },"organizer": {
            "@type": "Organization","name": "Kira and Morrison Music","url": "https://kiraandmorrisonmusic.com"
          }
        },{
          "@context": "https://schema.org","name": "The Adventures of Kira and Morrison EVENT TWO","startDate": "2025-08-21T19:00-05:00","endDate": "2025-08-21T23:00-05:00","name": "The Adventures of Kira and Morrison EVENT THREE","startDate": "2025-09-21T19:00-05:00","endDate": "2025-09-21T23:00-05:00","url": "https://kiraandmorrisonmusic.com"
          }
        }]
        </script>
      </head>
      <body>
      </body>
    </html>

enter image description here

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...