Eleventy plugin to generate JSON-LD structured data.
This plugin is a remake of quasibit's @quasibit/eleventy-plugin-schema, it improves on his JSON-LD script implementation, you are no longer forced to use JSON-LD-values you don't need.
You can basically write your schema into the frontmatter without any restricions. Please refer to the files in demo.
The plugin adds a shortcode to generate JSON-LD structure (including the <script>
tag).
The shortcode supports all Schema types.
Install the package:
npm install --save @pautym/simply-schema-eleventy
Add the plugin to your Eleventy configuration
(usually .eleventy.js
):
const schema = require("@pautym/simply-schema-eleventy");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(schema);
};
Add data/front matter to your pages. Please refer to the files in demo. If you already have the value in other properties, you can use computed data to clone them.
Call the shortcode where you want the script to be displayed:
{% jsonLdScript meta %}
Follow the same Steps as listed above, but call this shortcode instead:
{% addJsonData meta %}
You can validate the structured data using one of the following tools:
quasibit for creating @quasibit/eleventy-plugin-schema!
MIT. See LICENSE.