@pautym/simply-schema-eleventy
v1.0.5
Published
Eleventy plugin to generate JSON-LD structured data.
Downloads
15
Maintainers
Readme
The simple way to write 11ty-schema
Eleventy plugin to generate JSON-LD structured data.
No Restrictions
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.
Installation
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);
};
Usage
Creating the 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 %}
Adding content to a hardcoded Schema in hindsight
Follow the same Steps as listed above, but call this shortcode instead:
{% addJsonData meta %}
Validation
You can validate the structured data using one of the following tools:
Thanks to:
quasibit for creating @quasibit/eleventy-plugin-schema!
License
MIT. See LICENSE.