This plugin is no longer maintained.

Schema plugin for Craft CMS

A fluent builder of Schema.org types and ld+json generator based on Spatie's schema-org package which makes for a fast and easy way to add structured data to your templates.

Support Open Source. Buy beer.

This plugin is licensed under a MIT license, which means that it's completely free open source software, and you can use it for whatever and however you wish. If you're using it and want to support the development, buy me a beer over at Beerpay!

Beerpay

Requirements

This plugin requires Craft CMS 3.0.0-RC1 or later and PHP 7.

Schema Overview

Schema provides a fluent builder for all Schema.org types and their properties. For more information and the available methods, check out spatie/schema-org.

Using Schema

Once Schema is installed, it's accessible through the craft variable in your templates.

For the best experience, set the schema to a variable and typehint it to Spatie's model. In combination with the Symfony plugin for PHPStorm, you get autocompletion for all the Schema's and their properties.

For example:

{# @var schema \Spatie\SchemaOrg\Schema #}
{% set schema = craft.schema %}
{{ schema
    .person
      .name("Rias Van der Veken")
      .email("hello@rias.be")
      .company(
        schema.localBusiness
          .name("Marbles")
          .address(schema.postalAddress
            .addressCountry("Belgium")
            .addressLocality("Antwerp")
            .addressRegion("Antwerp")
            .postalCode(2000)
            .streetAddress("IJzerenpoortkaai 3")
          )
      )
}}

Generates the following output:

<script type="application/ld+json">
{  
   "@context":"http:\/\/schema.org",
   "@type":"Person",
   "name":"Rias Van der Veken",
   "email":"hello@rias.be",
   "company":{  
      "@type":"LocalBusiness",
      "name":"Marbles",
      "address":{  
         "@type":"PostalAddress",
         "addressCountry":"Belgium",
         "addressLocality":"Antwerp",
         "addressRegion":"Antwerp",
         "postalCode":2000,
         "streetAddress":"IJzerenpoortkaai 3"
      }
   }
}
</script>
Installation Instructions

To install this plugin, copy the command above to your terminal.

Reviews

This plugin doesn't have any reviews.

Active Installs
116
Version
1.0.3
License
MIT
Compatibility
Craft 3
Last release
January 14, 2018
Activity (30 days)
0
Closed Issues
0
Open Issues
0
Merged PRs
0
Open PRs