Astro + Sanity
Build a section library your team and AI can use.
Six chapters on planning, modelling and running a library of reusable page sections. With sample Sanity schemas, decision rules, a table of what AI may change, and test checklists.
A section library is a set of reusable page sections, each with its own design, Sanity schema, Astro component and usage note. Editors build pages by stacking them, and an AI tool can draft pages from the same list. To build one, audit your real pages, merge what repeats, model each section with narrow fields and rules, set up the Studio for editors, keep AI to drafts with permissions, and name an owner. This guide covers each step.
Chapters
Read it in order,
or jump in.
- 01
Why sections, not pages
A page is a one-off. A section is a part you can use again, with rules attached. Here is what that changes for your team, and how to tell if you need it.
5 min - 02
Planning the library
Most of a good library is decided before any code. Audit what you have, merge what repeats, name each section by its job and write down the recipes.
6 min - 03
Sanity schemas for sections
How to turn your plan into code: a page with a sections array, narrow fields, variants as fixed lists, rules on every field and an Astro component for each type.
6 min - 04
Studio for marketers
A good schema can still feel bad to use. How to set up the insert menu, previews, validation messages, live preview and publishing so editors need no help.
6 min - 05
AI page building with guardrails
What to let an AI change, how to limit its access through the Sanity MCP, what to write in its instructions, and how a person reviews every page before it goes live.
6 min - 06
Testing and governance
Libraries decay without rules. What to test on each section, how a new one gets added, how to change a section without breaking live pages, and who owns what.
6 min
What you get
6 chapters that each end with a clear next move.
- A section is four things together: design, schema, component and usage note.
- Audit real pages and your roadmap, then log every block in one sheet.
- One sections array, with only your named types listed in of.
- Group the insert menu by job, and give every section a preview picture.
- AI drafts, a person publishes. Enforce that with permissions, not prompts.
- Test at the extremes, on one page that shows every section and variant.
Who it is for
Marketing leads, designers and developers who run a marketing site on Astro and Sanity, or who are planning one, and want editors or AI to build pages safely.
Planning a section library? Book a free 20 minute callKeep a copy
Take the whole guide
as a PDF.
It all stays free to read here. If you want a copy for your team, leave your email and the download link shows up right away.
Thanks. Use it, share it, and tell us what is missing.
Download the PDFDownload the PDFFAQs
Questions
people ask.

A set of reusable page sections, each with a design, a Sanity schema, an Astro component and a note on when to use it. Pages are ordered lists of these sections. See our section library page for what we build.
Your audit decides. Our usual starting point for a marketing site is 20 or more, each with two to four variants, but a site with one offer may need fewer. If editors skip most of the list, you have too many.
Same fields with a different look is a variant. Different fields is a new section. If a variant would hide more than a couple of fields, make it a separate section.
The @sanity/astro docs say Visual Editing works only on server-rendered pages. A common answer is a static live site plus a separate server-rendered preview build, from the same code. Check the current docs.
The Sanity MCP has a publish tool, so this depends on the access you give it. We set AI up to save drafts, and a person reviews and publishes. Limit this with roles, then test that a publish attempt is refused.
Not on their own. Sanity says schema rules only run in the Studio, and its MCP docs say custom validation rules are skipped through MCP. Add your own check before review, such as sanity documents validate.
Changing a schema does not change saved content, so old pages may stop matching. Sort changes by risk. New optional fields are low risk. Renames need a planned migration, tested on a copy first.


