Skip to content

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 (No Code): Select schema_type on a Template Rule (seo-mappings) or per-page SEO editor (WebPage, Article, NewsArticle, BlogPosting, Product, Service, Event, FAQPage, AboutPage, ContactPage, CollectionPage, ItemPage, or None). For Product and Event, map ProcessWire fields directly in the Template Rule.
  • Code-First (SchemaProviderInterface / AbstractSchemaProvider): Implement buildSeoSchema(SchemaBuilder $schema, SchemaContext $context): void directly on a Custom Page class (site/classes/YachtPage.php) or register a standalone provider class via $seo->schemas()->register('yacht', YachtSchemaProvider::class).

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);
  • 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().

Build valid nested Schema.org objects without hand-typing boilerplate:

  • SchemaBuilder::offer(...) and SchemaBuilder::aggregateOffer(...)
  • SchemaBuilder::propertyValue($name, $value) and SchemaBuilder::quantitativeValue(...)
  • SchemaBuilder::aggregateRating(...)
  • SchemaBuilder::place(...)
  • SchemaBuilder::imageObject(...)
  • SchemaBuilder::ref($id) (creates ['@id' => $id] cross-links)
  • SchemaBuilder::parseNumericPrice($raw)

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, unreviewed Product cleanly to a standard page node with a warning diagnostic rather than emitting invalid rich-result markup.
  • MissingOfferPolicy::KeepEntity: Retains the Product node and attaches an info diagnostic.

SchemaBuilder also surfaces diagnostics for missing required Event fields (startDate, location), missing LocalBusiness.address, and declarative FAQPage nodes without mainEntity.

Next steps