The short answer
Build from sections when your team makes new pages often and those pages share the same building blocks. A section is one reusable part of a page, such as a hero or a FAQ, with its own fields, a few approved variants and rules. A page becomes an ordered list of those parts. Design and code happen once, per section. New pages then cost mostly writing time.
If you want the plain overview first, read Astro and Sanity for marketing teams. Our section library page shows what we build. This guide is the working manual: how to plan, model, test and run a library on Astro and Sanity, including how AI fits in.
What goes wrong when you build by the page
Most sites start page by page, and that is fine for the first ten pages. The trouble starts when someone needs page eleven by Friday.
- Pages get copied. Someone duplicates the closest page and edits it. Each copy now has its own small differences.
- Fixes do not travel. A better form or a clearer button goes on one page. The others keep the old one, and nobody can list which ones.
- Design drifts. Spacing, heading sizes and button labels slowly stop matching.
- The queue grows. Every new layout needs a designer and a developer, so simple pages wait behind product work.
- Speed slips. One-off pages bring one-off scripts and images, and no one owns the total.
None of this is anyone's fault. It is what happens when the unit of work is the page. Change the unit, and most of these problems get smaller.
What a section is, exactly
"Section" gets used loosely. In this guide, it means four things that ship together. If one is missing, you have a design idea, not a library item.
| Part | Where it lives | What it does |
|---|---|---|
| Design | Figma or your design file | Shows the section at every screen size, in each variant |
| Schema | Sanity, defined in code | Sets the fields an editor fills in, and what counts as valid |
| Component | Astro code | Turns the saved content into HTML and CSS |
| Usage note | The Studio and a short written guide | Says when to use this section, and when to pick another |
The usage note is the part teams skip, and it matters more once AI is involved. An AI tool, like a new hire, can only follow rules someone wrote down.
How a page is stored and built
Here is the whole idea in five steps. Chapter 3 shows the code.
- A page in Sanity is a document with a few page-level fields, such as title and slug, and one array called
sections. - Each item in that array is an object with its own type, such as
heroorfaq. Sanity stores that type name with the content as_type. - At build time, Astro fetches the page and walks through the array in order.
- For each item, it looks up the component with the same name and passes in the fields.
- The result is a normal HTML page. Visitors never touch the CMS.
Because a page is data, reordering is easy, fixes reach every page that uses a section at the next build, and a tool can read exactly what is on each page.
Three ways to run a marketing site
A section library sits between two other models. Each one is right for someone.
| Fixed templates | Section library | Free canvas | |
|---|---|---|---|
| How a page is made | Fill in one set layout | Stack approved sections in any sensible order | Place anything anywhere |
| Editor freedom | Low | Medium, on purpose | High |
| Risk of off-brand pages | Low | Low | High |
| Setup work | Low | Higher, up front | Depends on the platform |
| Best for | Many pages with one shape, such as blog posts | Campaign, feature and landing pages that vary | Small teams with a designer doing the editing |
Most real sites mix them. Blog posts and CMS content stay on fixed templates. Marketing pages use the library. Keep them apart in your head: a section library is for pages that need different shapes.
When a library is not worth it
A library is an investment, and it does not always pay back. Skip it, or wait, if any of these is true:
- You make a new page only a few times a year.
- Every page you make is truly different, such as a brand site led by art direction.
- Your site is stable and your team is happy on its current tool. If the only pain is a messy CMS, tidy that first.
- Nobody will own the library after launch. Without an owner, it decays like anything else.
Decision rule List the pages you made in the last six months. Sort them by shape. If most of them could be built from the same small set of parts, a library will help. If you made only a handful, or each one needed a new design, spend the money elsewhere.
A section library also does not require Sanity. You can run a similar idea in other tools. See headless CMS options for marketing sites, and our Webflow CMS work if a simpler setup suits you better.
The shape this guide works towards
The team gives an AI tool the content. The AI picks sections from the library, fills them in and hands back a staging link. If the team likes the page, it goes live. If something needs to change, they say what.
We have built this setup with a section library in Sanity, connected to AI through the Sanity MCP, with marketing skills we wrote. The sample schemas in later chapters are examples we wrote for this guide. They are not any client's code.
Who needs to be in the room
A library touches several jobs. Bring these people in before anyone designs a section.
- Marketing lead. Knows which pages are coming, and decides what the library must make easy.
- Designer. Owns how sections look, and which variants are allowed.
- Developer. Owns schemas, components and the build.
- Editor. The person who will really build pages. Test everything on them.
- One named owner. Often the marketing lead or the developer. Decides what gets added, and what gets retired.
One person can hold several of these jobs. What you cannot do is leave one empty.
Done when You can say why you want a library in one sentence with a person in it, such as "Our campaign lead should be able to build a landing page without a developer," and you have named the owner.


