@quasibit/eleventy-plugin-schema
v1.13.0
Published
Eleventy plugin to generate JSON-LD structured data.
Readme
eleventy-plugin-schema
Eleventy plugin to generate JSON-LD structured data.
Installation
Install the package:
npm install --save @quasibit/eleventy-plugin-schemaAdd the plugin to your Eleventy configuration.
ESM (Eleventy 2.0+):
// eleventy.config.js
import schema from "@quasibit/eleventy-plugin-schema";
export default function(eleventyConfig) {
eleventyConfig.addPlugin(schema);
}CommonJS:
// .eleventy.js
const schema = require("@quasibit/eleventy-plugin-schema");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(schema);
};Introduction
The plugin adds two shortcodes to generate the JSON-LD script:
jsonLdScript(includes the<script>tag)jsonLd(just JSON-LD without the<script>tag)
The shortcodes support the following schema types:
- WebSite.
- BlogPosting.
- WebPage.
- Product (thanks @christopherpickering).
- Organization (thanks @christopherpickering).
- Breadcrumbs (thanks @christopherpickering).
- SearchAction (thanks @christopherpickering).
- FAQPage (thanks @christopherpickering).
- Videos (thanks @christopherpickering).
- Article - Generic article type.
- NewsArticle - News content with print info.
- LocalBusiness - Local business with address, hours, geo.
- Event - Conferences, webinars, concerts.
- HowTo - Tutorial/guide with steps.
- Recipe - Food/cooking content with ingredients.
- JobPosting - Career pages and job boards.
- Course - Educational/online learning content.
- Book - Books with readAction support (#27).
- TechArticle - Technical documentation with proficiency level.
Usage
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:
Nunjucks:
{% jsonLdScript meta, type, tags %}Liquid:
{% jsonLdScript meta type tags %}And if you don't want the <script> tag, then use this instead:
Nunjucks:
{% jsonLd meta, type, tags %}Liquid:
{% jsonLd meta type tags %}Validation
You can validate the structured data using one of the following tools:
Related plugins
- @quasibit/eleventy-plugin-sitemap: generate a sitemap.
Maintainers
Special thanks to @christopherpickering.
License
MIT. See LICENSE.
