JSON-LD Schema.org: Multiple video/image page
Asked Answered
R

1

30

I can't figure out how you would define a bunch of videos on the same page. i.e. a search page. Let's say you've a site that returns 50 different videos. Then how are you supposed to define this with JSON-LD?

Rhettrhetta answered 28/5, 2015 at 11:50 Comment(0)
S
54

If you have multiple items as value of a property, you could use an array:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebPage",
  "video":
  [
    {
      "@type": "VideoObject"
    },
    {
      "@type": "VideoObject"
    }
  ]
}
</script>

If you have multiple items on the top-level (not as value of a property), you could use a (named) graph and an array:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@graph": 
  [
    {
       "@type": "VideoObject"
    },
    {
       "@type": "VideoObject"
    }
  ]
}
</script>

And you could of course use multiple script elements:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebPage",
  "video": 
  {
    "@type": "VideoObject"
  }
}
</script>

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebPage",
  "video": 
  {
    "@type": "VideoObject"
  }
}
</script>
Scad answered 28/5, 2015 at 12:22 Comment(1)
(Note that this is just example code, not tailored to your specific case. If you wonder which Schema.org types and properties you should use, this should be a separate question.)Scad

© 2022 - 2024 — McMap. All rights reserved.