Sanity plugin for Google structured data schema integration?

4 replies
Last updated: Apr 27, 2020
A personal reflection that I have: as Sanity is focused on content modelling, wouldn't it be natural to propose thru a plugin a natural exposition to Google structured data schema for instance?
I'm implementing a collection of Events (json-ld structured data schemas from Google reference), but I feel a little bit like reinventing the wheel (on the top of localization).

I'm talking of the Event schema but the same thing applies to Article, BreadcrumbList, Person, Organization, Webpage... etc... etc...

I mean that it is finally bringin content to its achievement no?

Does Sanity has an opinion on that?
AI Update

Great question! This is something many developers think about when working with structured content, and you're absolutely right that it feels like a natural fit for Sanity's content modeling approach.

The good news: There is actually a Schema Markup plugin that helps with generating structured data for various content types. This plugin simplifies the process of creating schema.org markup for your Sanity documents.

Why there isn't more out-of-the-box: While Sanity doesn't ship with pre-built schema.org schemas as core document types, this is likely intentional. Here's why:

  1. Flexibility over prescription - Schema.org types like Event, Article, Person, etc. are often just a starting point. Most real-world content needs additional fields, different validation rules, or custom structures that go beyond the basic schema.org spec. If Sanity provided rigid schema.org types, you'd likely end up fighting against them or extending them anyway.

  2. Structured data is output, not storage - As mentioned in Sanity's SEO optimization course, JSON-LD structured data is typically generated at render time from your content. You might have a rich "Event" document in Sanity with lots of internal fields, but only map a subset to the schema.org Event format for JSON-LD output.

  3. Localization complexity - You mentioned localization, and this is a perfect example. How schema.org types should be localized varies by implementation. Some fields should be translated, others shouldn't. This is very project-specific.

Practical approach: Many developers create their own schema.org-aligned document types as reusable schemas within their projects, or use the Schema Markup plugin mentioned above. The community has discussed this and some have even suggested publishing reusable schema.org-based schemas as community plugins.

Sanity's take: Their philosophy seems to be that structured data generation is part of the "content enrichment" layer - you model your content for editorial needs first, then transform it into schema.org formats at the presentation layer. Since "structured data is what Sanity does best," the transformation is usually straightforward in your frontend code.

That said, if you're building Event schemas repeatedly, definitely consider packaging your solution as a plugin for others! The community would likely appreciate it, and it sounds like you're already doing the work anyway.

Show original thread
4 replies
We have thought about this, and actually, nothing keeps you from re-creating schema.org schemas and publish them as plugins (for example
sanity install schema-org-event
)
That being said, from a practical standpoint I find the
schema.org models a bit too fine-grained, not always editor friendly, and often not exactly fitting to what makes sense for a use case or organization. But it's probably a good place to find inspiration!
And you can still generate JSON-LD and
schema.org compatible structures even if you don't have it 1:1 in the Studio, since you can remap fields etc.
And yeah, that's like, just our opinion, you are of course welcome to do what makes sense for you!
Thanks for the advice.I agree with you on the practical standpoint: I feel the same way.
Since Sanity is referencing data thru schema, it integrates well the real-time aspect of the problem.
We also find schema.org as a great starting point but probably not a good ending point. Their goals are a little different from ours, and the tools at their disposal are more primitive (harder to have references between models, so more is inlined). I always look at the schema.org models for anything I’m starting to model though and its proved worthwhile.

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?