justbetter / statamic-structured-data
Package info
github.com/justbetter/statamic-structured-data
pkg:composer/justbetter/statamic-structured-data
Requires
- php: ^8.4|^8.5
- laravel/framework: ^12.0|^13.0
- statamic/cms: ^6.0
Requires (Dev)
- larastan/larastan: ^3.4
- laravel/pint: ^1.29
- orchestra/testbench: ^10.3|^11.0
- pestphp/pest: ^3.7
- phpstan/phpstan-mockery: ^2.0
- phpunit/phpunit: ^11.5
This package is auto-updated.
Last update: 2026-05-20 12:37:53 UTC
README
Statamic Structured Data
This Statamic addon provides a powerful and flexible way to add structured data (JSON-LD) to your Statamic website. It allows you to define structured data templates and automatically inject them into your pages, improving your site's SEO and making your content more understandable for search engines.
Features
- 🔄 Dynamic JSON-LD generation based on entry and term data
- 📝 Template-based structured data configuration
- 📦 Built-in schema presets (WebSite, WebPage, Organization, Article, LocalBusiness)
- 🎯 Support for multiple schemas per page
- 🛠 Antlers template parsing support
- 🧩 Support for replicator-to-JSON-LD field mapping
- 💪 Flexible and extensible architecture
Requirements
- PHP ^8.4 or ^8.5
- Laravel ^12.0
- Statamic ^6.0
Installation
You can install this addon via Composer:
composer require justbetter/statamic-structured-data
After installing make sure to load the Structured Data tag in your head.
Blade:
{!! Statamic::tag('structured-data:head')->fetch() !!}
Antlers
{{ structured-data:head }}
Configuration
Make sure to publish the config by running:
php artisan vendor:publish --tag=justbetter-structured-data
You can now find the config file at config/justbetter/structured-data.php.
After publishing the config, you can configure:
- which collections support structured data templates
- which taxonomies support structured data objects
- whether presets are enabled
- which default presets are available
- custom preset paths
Usage
1. Creating Structured Data Templates
Create templates in your Statamic control panel that define your structured data schemas. Each template can contain multiple schema definitions with:
- Special properties (@context, @type, @id)
- Custom fields with various data types (strings, numeric, arrays, objects)
- Dynamic values using Antlers templating syntax
2. Assigning Templates to Entries
In your entry or term's content, you can assign one or more structured data templates using the structured_data_templates field. The addon will automatically process these templates and generate the appropriate JSON-LD scripts.
3. Rendering Structured Data
Render the generated JSON-LD where you need it in your layout:
Blade:
{!! Statamic::tag('structured-data:head')->fetch() !!}
Antlers:
{{ structured-data:head }}
Example Schema
Here's an example of how you might structure a basic Organization schema:
{
"specialProps": {
"context": "https://schema.org",
"type": "Organization",
"id": "https://example.com"
},
"fields": [
{
"key": "name",
"type": "string",
"value": "{{ company_name }}"
},
{
"key": "url",
"type": "string",
"value": "{{ config:app:url }}"
}
]
}
Credits
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
The MIT License (MIT). Please see License File for more information.