Schema.org & JSON-LD
Every page rendered by Seo automatically emits a linked Schema.org JSON-LD @graph connecting your site’s #identity, #website, #creator, #webpage, and #breadcrumb nodes via stable @id URIs. When your domain needs rich structured data (such as yacht charter offers, multi-day tours, events, or filtered collection listings), use the code-first SchemaBuilder API.
Declarative vs. Code-First Schema
Section titled “Declarative vs. Code-First Schema”- Declarative (No Code): Select
schema_typeon a Template Rule (seo-mappings) or per-page SEO editor (WebPage,Article,NewsArticle,BlogPosting,Product,Service,Event,FAQPage,AboutPage,ContactPage,CollectionPage,ItemPage, orNone). ForProductandEvent, map ProcessWire fields directly in the Template Rule. - Code-First (
SchemaProviderInterface/AbstractSchemaProvider): ImplementbuildSeoSchema(SchemaBuilder $schema, SchemaContext $context): voiddirectly on a CustomPageclass (site/classes/YachtPage.php) or register a standalone provider class via$seo->schemas()->register('yacht', YachtSchemaProvider::class).
Real-World Example: YachtSchemaProvider
Section titled “Real-World Example: YachtSchemaProvider”This provider (from site/modules/Seo/examples/real-world/YachtSchemaProvider.php) emits a linked Product + Offer + PropertyValue + BreadcrumbList graph on detail pages (view mode) and a CollectionPage + ItemList graph on fleet listings (list mode) with zero extra database queries:
<?php
declare(strict_types=1);
namespace ProcessWire;
use Totoglu\Seo\Schema\AbstractSchemaProvider;use Totoglu\Seo\Schema\MissingOfferPolicy;use Totoglu\Seo\Schema\SchemaBuilder;use Totoglu\Seo\Schema\SchemaContext;
final class YachtSchemaProvider extends AbstractSchemaProvider{ protected function buildView(SchemaBuilder $schema, SchemaContext $context): void { $page = $context->page; if (!$page instanceof Page || !$page->id) { return; }
$weeklyRate = SchemaBuilder::parseNumericPrice($page->get('weekly_rate') ?: 24500); $schema->setMissingOfferPolicy(MissingOfferPolicy::Fallback);
$schema->product([ 'name' => $context->title, 'description' => $context->description, 'sku' => 'AV-' . $page->id, 'offers' => SchemaBuilder::offer( price: $weeklyRate, currency: 'EUR', availability: 'https://schema.org/InStock', url: $context->canonicalUrl, ), 'additionalProperty' => [ SchemaBuilder::propertyValue('Length', '32 m'), SchemaBuilder::propertyValue('Home Port', 'Gocek, Turkey'), ], ]);
$schema->breadcrumbs(); }
protected function buildList(SchemaBuilder $schema, SchemaContext $context): void { $schema->collectionPage([ 'name' => $context->title, 'description' => $context->description, ]);
if ($context->hasItems()) { $schema->itemList($context->items); }
$schema->breadcrumbs(); }}Register the provider in site/ready.php (or lazily via 'seoSchemas' pull-discovery in a module’s getModuleInfo()):
<?php
declare(strict_types=1);
namespace ProcessWire;
$wire->seo->schemas()->register('yacht', YachtSchemaProvider::class);SchemaBuilder Node & Helper Reference
Section titled “SchemaBuilder Node & Helper Reference”Page & Entity Graph Builders
Section titled “Page & Entity Graph Builders”- Page Nodes:
webPage(),collectionPage(),searchResultsPage(),itemPage(),disableWebPage(). - Domain Entities:
entity(),product(),article(),event(),service(),localBusiness(),itemList(),faq(),breadcrumbs(),disableBreadcrumbs(). - Low-Level Graph Control:
node(),addNode(),removeNode(),hasNode(),getNode(),addRawJson().
Static Value Helpers
Section titled “Static Value Helpers”Build valid nested Schema.org objects without hand-typing boilerplate:
SchemaBuilder::offer(...)andSchemaBuilder::aggregateOffer(...)SchemaBuilder::propertyValue($name, $value)andSchemaBuilder::quantitativeValue(...)SchemaBuilder::aggregateRating(...)SchemaBuilder::place(...)SchemaBuilder::imageObject(...)SchemaBuilder::ref($id)(creates['@id' => $id]cross-links)SchemaBuilder::parseNumericPrice($raw)
MissingOfferPolicy & SchemaDiagnostic
Section titled “MissingOfferPolicy & SchemaDiagnostic”Search engines require Product rich results to include offers, review, or aggregateRating. SchemaBuilder checks this automatically and records structured SchemaDiagnostic messages inspectable via $bag->schemaDiagnostics() and in the Live Preview JSON-LD tab:
MissingOfferPolicy::Fallback(default): Degrades an unpriced, unreviewedProductcleanly to a standard page node with awarningdiagnostic rather than emitting invalid rich-result markup.MissingOfferPolicy::KeepEntity: Retains theProductnode and attaches aninfodiagnostic.
SchemaBuilder also surfaces diagnostics for missing required Event fields (startDate, location), missing LocalBusiness.address, and declarative FAQPage nodes without mainEntity.