Structured Data (JSON-LD)
Unfold CMS generates JSON-LD structured data to help search engines understand your content. This enables rich results in Google Search, including article snippets, breadcrumbs, organization info, and site search boxes.
Overview
Structured data is included on every page via the @stack('schema') Blade stack. The CMS provides helper functions that generate Schema.org-compliant JSON-LD objects.
Built-in Schema Types
Organization Schema
Added to the homepage. Includes your site name, URL, logo, and social profiles.
schema_organization()
Generates:
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "My Website",
"url": "https://example.com",
"logo": "https://example.com/storage/logo.png",
"sameAs": [
"https://facebook.com/mysite",
"https://twitter.com/mysite"
]
}
The organization schema pulls data from:
app.name— Organization nameapp.logo— Logo image URLsocial.*— Social media profile URLs (Facebook, Twitter, Instagram, LinkedIn, YouTube, GitHub)
Website Schema
Added to the homepage. Includes a SearchAction that enables a sitelinks search box in Google results.
schema_website()
Generates:
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "My Website",
"url": "https://example.com",
"potentialAction": {
"@type": "SearchAction",
"target": "https://example.com/search?q={search_term_string}",
"query-input": "required name=search_term_string"
}
}
Article Schema
Added to blog post pages. Includes the article title, author, dates, image, and publisher information.
schema_article($post)
Generates:
{
"@context": "https://schema.org",
"@type": "Article",
"headline": "Getting Started with Laravel",
"description": "Learn how to build your first Laravel application...",
"image": "https://example.com/storage/posts/featured.jpg",
"datePublished": "2025-03-15T10:00:00+00:00",
"dateModified": "2025-03-16T14:30:00+00:00",
"author": {
"@type": "Person",
"name": "John Doe"
},
"publisher": {
"@type": "Organization",
"name": "My Website",
"logo": {
"@type": "ImageObject",
"url": "https://example.com/storage/logo.png"
}
}
}
WebPage Schema
Added to static pages. Includes the page title, description, and URL.
schema_webpage($page)
Breadcrumb Schema
Added to any page with breadcrumb navigation. Helps search engines display breadcrumb trails in results.
schema_breadcrumb_list([
['name' => 'Home', 'url' => url('/')],
['name' => 'Blog', 'url' => route('blog.index')],
['name' => 'Post Title', 'url' => url()->current()],
])
Generates:
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://example.com"
},
{
"@type": "ListItem",
"position": 2,
"name": "Blog",
"item": "https://example.com/blog"
},
{
"@type": "ListItem",
"position": 3,
"name": "Post Title",
"item": "https://example.com/blog/post-title"
}
]
}
Usage in Templates
Layout Setup
Your template layout must include the schema stack in the <head> or before </body>:
<head>
{!! seo() !!}
@stack('schema')
@stack('head')
</head>
Adding Schema to Pages
Use @push('schema') to add structured data to specific pages:
{{-- Homepage --}}
@push('schema')
<script type="application/ld+json">
{!! json_encode(schema_organization(), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) !!}
</script>
<script type="application/ld+json">
{!! json_encode(schema_website(), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) !!}
</script>
@endpush
{{-- Blog post --}}
@push('schema')
<script type="application/ld+json">
{!! json_encode(schema_article($post), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) !!}
</script>
@endpush
{{-- Static page with breadcrumbs --}}
@push('schema')
<script type="application/ld+json">
{!! json_encode(schema_webpage($page), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) !!}
</script>
<script type="application/ld+json">
{!! json_encode(schema_breadcrumb_list([
['name' => __('Home'), 'url' => setting_get('app.url')],
['name' => $page->title, 'url' => url()->current()],
]), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) !!}
</script>
@endpush
Using the @jsonld Directive
For cleaner syntax, you can also use the @jsonld Blade directive:
@jsonld(schema_organization())
@jsonld(schema_article($post))
@jsonld(schema_breadcrumb_list($breadcrumbs))
Configuration
Structured data uses values from your site settings:
| Setting | Used In | Source |
|---|---|---|
| Site Name | Organization, Website | app.name |
| Logo | Organization, Article publisher | app.logo |
| Social URLs | Organization sameAs |
social.facebook, social.twitter, etc. |
| Site URL | All schemas | app.url |
Ensure your site settings are configured in Settings > General and Settings > Social Links for accurate structured data.
Validation
Test your structured data using:
Related
- Meta Tags — Title tags and Open Graph
- Template Development — Full template implementation guide
- Helper Functions — Complete helper reference