SEO
True\SEO generates JSON-LD structured-data scripts for common schema.org types — articles, recipes, products, organizations, breadcrumbs — plus a complete schema "graph" tying a page's structured data together. Drop the output inside <head> and search engines pick it up.
Per-page JSON-LD
The jsonLD() method returns a ready-to-embed <script type="application/ld+json"> tag for the supplied schema type:
use True\SEO;
$seo = new SEO;
$html = $seo->jsonLD('recipe', [
'name' => 'Chocolate Cake',
'description' => 'A delicious chocolate cake recipe',
'author' => 'John Doe',
]);
echo $html;
Produces:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Recipe",
"name": "Chocolate Cake",
"description": "A delicious chocolate cake recipe",
"author": "John Doe"
}
</script>
Supported types
recipearticleorganizationwebsitewebpageblogpostbreadcrumbsstorehomeandconstructionbusinessproduct
Breadcrumb data
If you'd rather not author breadcrumb entries by hand on every page, generateBreadcrumbs() derives them from the request URI. Pass an INI file to override the auto-generated labels:
; app/data/breadcrumbs.ini
/ = "Home"
/contact.html = "Contact Us"
$crumbs = $seo->generateBreadcrumbs(BP.'/app/data/breadcrumbs.ini');
print_r($crumbs);
// => [[ 'name' => 'Home', 'url' => '/' ], ...]
Feed the array straight into jsonLD('breadcrumbs', $crumbs) or into the schema graph below.
The schema graph
schemaGraph() emits a single @graph JSON-LD block that ties together the WebSite, WebPage, Organization, and BreadcrumbList for one page — exactly the bundle Google's structured-data tools expect to see:
$info = (object) [
'url' => 'https://example.com',
'title' => 'Example Website',
'description' => 'An example website description',
'site_logo_url' => 'https://example.com/logo.png',
'site_logo_width' => 300,
'site_logo_height' => 100,
'site_logo_caption' => 'Example Logo',
'datePublished' => '2023-01-01',
'dateModified' => '2024-01-01',
'social_media' => [
'https://facebook.com/example',
'https://twitter.com/example',
],
'breadcrumbs' => [
['name' => 'Home', 'url' => '/'],
['name' => 'About', 'url' => '/about/'],
],
];
echo $seo->schemaGraph($info);
Where to render it
Echo the returned strings inside <head>. If you already use the view's built-in breadcrumb support or {jsonld} blocks, reach for those first — they keep the markup with the page meta. Use True\SEO when you need types or graph shapes the view layer doesn't cover.