json-ld-structured-data
Skill0 starsChanged 48 days agoMITView on GitHub
Add schema.org JSON-LD structured data to Laravel Blade pages as one request-scoped @graph: Organization/NGO/LocalBusiness, WebSite with sitelinks search, BlogPosting, BreadcrumbList and FAQPage, safely escaped. Use when adding structured data, schema markup, rich results, Google knowledge panel details, breadcrumbs or FAQ snippets, or fixing Rich Results Test errors.
In this repository11 other files it gives its agents.
- bot-proof-formsSkill
- image-uploadsSkill
- inertia-admin-tablesSkill
- mpesa-stk-pushSkill
- paypal-checkoutSkill
- pre-push-checksSkill
- secrets-scannerSkill
- seo-crawlabilitySkill
- shared-network-rate-limitsSkill
- social-share-previewsSkill
- wordpress-migrationSkill
The file
Files
JSON-LD structured data
Search engines and AI assistants read JSON-LD to learn who publishes a site, what each page is, and how pages relate. This skill prints one @graph per page. The organisation and website appear on every page, and each view adds its own entities: an article, breadcrumbs or FAQs. Everything is linked by @id.
Install
- Copy from
stubs/, dropping.stub:app/Support/StructuredData.php,app/Providers/StructuredDataServiceProvider.php,config/structured-data.php,tests/Feature/StructuredDataTest.php. - Register the provider in
bootstrap/providers.php(Laravel 11+). - Fill in
config/structured-data.php: the most specific type (NGO,LocalBusiness,Restaurant...), logo, address and official profiles (same_as). - In the layout's
<head>:{{ app(\App\Support\StructuredData::class)->toScript() }} - In page views, before the layout renders:
Also@php $ld = app(\App\Support\StructuredData::class); $ld->addArticle([ 'url' => route('posts.show', $post), 'headline' => $post->title, 'description' => $post->excerpt, 'image' => $post->image_url, 'published_at' => $post->published_at, 'updated_at' => $post->updated_at, 'author' => $post->author_name, ]); $ld->addBreadcrumbs([['name' => 'Home', 'url' => url('/')], ['name' => 'Blog', 'url' => route('posts.index')], ['name' => $post->title]]); @endphpaddFaqs([['question' => ..., 'answer' => ...]]), oradd([...])for any other schema.org type (Event, Product, Course...). - Validate a few URLs with Google's Rich Results Test and the Schema.org validator.
Rules
- Request-scoped, and reset after each response. A plain singleton makes entities from one page appear on the next in tests and on Octane. The provider registers it as
scopedand forgets it onRequestHandled. The test "entities from one request never leak into the next" guards this. - Escape for HTML, not only JSON.
json_encodewithJSON_HEX_TAG | JSON_HEX_AMPturns<and>into</>, so a post titled</script><script>...can't inject a script. Never build JSON-LD by concatenating strings in Blade. - Mark up only what the page shows. FAQ answers, prices and ratings in JSON-LD must be visible on the page, or Google may ignore the page's markup or apply a manual action.
- Absolute URLs everywhere (
url(),route(),asset()), and an image for articles: without one they aren't eligible for article rich results. - Blade section order: with
@extends, the child view renders before the layout, so entities added in sections are ready when<head>prints. With component layouts (<x-layout>), add entities before the component tag, or in the controller. - One organisation
@id(url('/').'#organization') referenced aspublisherandauthorfallback. Don't repeat the organisation's details on every entity. - Blade gotcha: an inline
@php(...)before a block@php ... @endphpin the same file breaks parsing. Use the block form.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

