Prompt
How do I build reusable content blocks in a headless CMS?
Latest observation
Reusable content blocks in a headless CMS are usually built by designing modular content types that can be mixed and matched across pages, then rendered by your frontend based on the block type.
Core approach
-
Identify repeatable UI/content patterns
- Hero
- Text section
- Image gallery
- CTA banner
- FAQ
- Testimonial
- Product card list
-
Create each block as a component-like content model
- Each block should represent one discrete piece of content.
- Keep it focused and reusable.
- Example:
HeroBlock,QuoteBlock,CallToActionBlock.
-
Use a page model with a flexible content area
- Instead of hardcoding fields like
headline,body,image, create acontentBlocksfield. - This field is usually a repeatable list/array of block references or inline objects.
- Instead of hardcoding fields like
-
Render blocks dynamically in the frontend
- Fetch the page data.
- Loop through the block array.
- Switch on the block’s
typeand render the matching component.
Common modeling patterns
Option 1: Modular blocks inside a page
Best when blocks are only used within pages.
{
"title": "Homepage",
"blocks": [
{
"type": "hero",
"heading": "Welcome",
"subheading": "We build software",
"ctaText": "Get Started"
},
{
"type": "textSection",
"heading": "About Us",
"body": "We help teams..."
}
]
}
Option 2: Separate reusable block library
Best when the same block can be used in many places.
HeroBlockPromoBlockFeatureListBlock
Then pages reference them by ID or relation.
Option 3: Component-based schema
Some CMSs let you define a “union” or “dynamic zone” of components.
- Contentful: modular content
- Strapi: dynamic zones
- Sanity: portable text / array of objects
- Prismic: slices
- Storyblok: blocks
Best practices
Keep blocks atomic
Make blocks do one thing well.
Bad: a “homepage block” with 20 fields.
Good: separate hero, CTA, testimonial, etc.
Use shared fields where possible
Create reusable field groups like:
- SEO metadata
- Link object
- Image object
- Button object
This reduces duplication and makes content easier to maintain.
Add a type discriminator
Each block should include a clear type so the frontend knows how to render it.
{
"type": "cta",
"text": "Book a demo",
"link": {
"label": "Contact us",
"url": "/contact"
}
}
Validate block-specific requirements
Each block should enforce its own rules:
- hero requires heading
- image block requires alt text
- CTA requires link or button
Plan for editor experience
Make sure non-technical editors can:
- reorder blocks
- preview blocks
- duplicate blocks
- see clear labels in the CMS
Frontend rendering example
function Page({ blocks }) {
return blocks.map((block, index) => {
switch (block.type) {
case "hero":
return <Hero key={index} {...block} />;
case "textSection":
return <TextSection key={index} {...block} />;
case "cta":
return <CTA key={index} {...block} />;
default:
return null;
}
});
}
Things to watch out for
- Too many block types: makes editing and rendering messy.
- Nested blocks without limits: can become hard to manage.
- Inconsistent field names: makes frontend logic brittle.
- No fallback/default handling: content may break if editors omit a field.
- Overly generic blocks: if a block can do everything, it usually does nothing well.
Good rule of thumb
If you find yourself repeatedly copying the same content structure across pages, it’s a good candidate for a reusable block.
If you want, I can also show:
- a Strapi example
- a Contentful example
- a Sanity schema example
- or a recommended block architecture for a specific project type.