# JSON Schema Plugin

**URL:** <https://forum.getkirby.com/t/json-schema-plugin/16967>\
**Category:** Plugins\
**Tags:** v3\
**Created:** [January 24, 2020, 10:08am UTC](https://forum.getkirby.com/t/json-schema-plugin/16967 "2020-01-24T10:08:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [January 24, 2020, 10:08am UTC](https://forum.getkirby.com/t/json-schema-plugin/16967/1 "2020-01-24T10:08:33Z")

</div>

Just published a little plugin for making structured schema for search engines. No more messing about manually with JSON in your templates 🙂

[https://github.com/HashandSalt/kirby3-schema](https://github.com/HashandSalt/kirby3-schema)

---

<div class="post-metadata">

**Author:** ![luxuryluke](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/luxuryluke/32/3701_2.png) [@luxuryluke](https://forum.getkirby.com/u/luxuryluke)\
**Post date:** [January 24, 2020, 9:55pm UTC](https://forum.getkirby.com/t/json-schema-plugin/16967/2 "2020-01-24T21:55:33Z")

</div>

As someone not too familiar with manually generating JSON, I’d love to learn how to use this plugin to save myself time, but I think I need more guidance on your GH page. When you have time, add in some more examples, if you would. Thanks!

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [January 24, 2020, 10:16pm UTC](https://forum.getkirby.com/t/json-schema-plugin/16967/3 "2020-01-24T22:16:34Z")

</div>

It really depends what you are trying to describe. For example, a simple example is describing a video on the page, which would look like this…

```auto
<?= $site->schema('VideoObject')
  ->name('Funny Cat Poses 2.0')
  ->description("A short description of your video, we'd keep it at 140 characters just to be safe.")
  ->thumbnailUrl('http://www.example.com/thumbnail.jpg')
  ->uploadDate('2015-04-05T08:00:00+02:00')
  ->duration('PT1M33S')
  ->contentUrl('http://www.example.com/movie.mp4')
  ->embedUrl('http://www.example.com/embed?videoetc')
  ->author($site->schema('Person')->name('Jason Bourne'))
   ?>

```

Which would generate:

```auto
<script type="application/ld+json">
{
  "@context": "https:\/\/schema.org",
  "@type": "VideoObject",
  "name": "Funny Cat Poses 2.0",
  "description": "A short description of your video, we'd keep it at 140 characters just to be safe.",
  "thumbnailUrl": "http:\/\/www.example.com\/thumbnail.jpg",
  "uploadDate": "2015-04-05T08:00:00+02:00",
  "duration": "PT1M33S",
  "contentUrl": "http:\/\/www.example.com\/movie.mov",
  "embedUrl": "http:\/\/www.example.com\/embed?videoetc",
  "author": {
    "@type": "Person",
    "name": "Jason Bourne"
  }
}
</script>

```

Of course, you can use PHP / Field values to fill them in.

There are sites like [Steal our JSON](https://jsonld.com/) that offer good starting points, but are not exhustive examples of what is possible. You can also run the page through [Google’s Structured data tool](https://search.google.com/structured-data/testing-tool) to validate it and improve.

I hope that helps.

---

<div class="post-metadata">

**Author:** ![luxuryluke](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/luxuryluke/32/3701_2.png) [@luxuryluke](https://forum.getkirby.com/u/luxuryluke)\
**Post date:** [January 24, 2020, 10:28pm UTC](https://forum.getkirby.com/t/json-schema-plugin/16967/4 "2020-01-24T22:28:03Z")

</div>

Thank you! This makes more sense already. Cheers! 😁 :kirby:

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [February 11, 2020, 10:30pm UTC](https://forum.getkirby.com/t/json-schema-plugin/16967/5 "2020-02-11T22:30:51Z")

</div>

@luxuryluke

Here is another example if it helps. i just worked out for generate breadcrumb schema using the plugin. If you (or anyone) knows how to shorten this, id love to hear about it 🙂

```auto
<?php

$itemListElement = [];

foreach($site->breadcrumb() as $crumb) {

$depth = $site->breadcrumb()->indexOf($crumb) + 1;

$itemListElement[] =
  $site->schema('ListItem')
  ->position($depth)
  ->item(['name' => $crumb->title()->value(), '@id' => $crumb->url()]);
}

echo $site->schema('BreadcrumbList')
->itemListElement($itemListElement);

?>

```
