jekyll-json-ld

jekyll-json-ld

An interface from Jekyll to the json-ld library. Turn front-matter YAML into beautiful linked data.

Jekyll-JSON-LD: JSON-LD Liquid Tags in Jekyll

An as-of-now very simple liquid filter that allows you to specify an object in the Front Matter YAML and render it into JSON-LD within your output.

WARNING

This is currently an extremely limited implementation that does little more than convert a YAML object to JSON. Validation, normalization etc. are yet to come.

Installation

Require the jekyll-json-ld gem using your favorite method, possibly:

group :jekyll_plugins do
  [...]
  gem "jekyll-json-ld"
end

Example

The object(s) can, for example, be specified in the Front Matter of a template, page or post:

---
layout: default
recipe:
  "@context": http://schema.org/
  "@type": Recipe
  name: "Grandma's Holiday Apple Pie"
  datePublished: 2015-12-24
  description: Is this a really tasty apple pie or have I fallen victim to some sort of culinary Stockholm Syndrom?
  recipeIngredient:
    - 500g brown sugar
    - 200ml Whiskey
---

...and so on. For references regarding defined schemes see https://developers.google.com/structured-data/ or Schema.org.

To run the YAML through the filter place (for this example) {{ page.recipe | json_ld_filter }} within the body of your document. This renders the following JSON-LD markup:

<script type="application/ld+json">
{
  "@context":"http://schema.org/",
  "@type":"Recipe",
  "name":"Grandma's Holiday Apple Pie",
  "datePublished":"2015-12-24",
  "description":"Is this a really tasty apple pie or have
    I fallen victim to some sort of culinary Stockholm Syndrom?",
  "recipeIngredient":
    ["500g brown sugar","200ml Whiskey"]
}
</script>
jekyll logo

Want a Jekyll website built?

Hire a Jekyll developer