Using a headless CMS — Cerette Astro
Connecting a headless CMS works the same for every Astro template sold on Framebrick, so this page lists only what is specific to Cerette.
Loaders and schemas, rich text, images, rebuilding on publish, and step-by-step guides for Sanity, Payload, Strapi and Directus are in Use a headless CMS with an Astro template.
Collections
Section titled “Collections”src/content.config.ts defines them, src/content/schemas.ts checks every entry when the site builds, and pages read
them through src/lib/content.ts: getProjects / getProject / getOtherProjects / getProjectServices,
getServices / getService, getTestimonials, getTeam, getPosts / getPost / getRelatedPosts,
getLegalPages / getLegalPage. To fetch a collection from a CMS, replace its loader and keep its schema, or rewrite
those functions; pages, sections and components stay unchanged. Mirror the schemas in the CMS:
| Collection | In the demo | Fields |
|---|---|---|
projects |
6 | slug, title, summary, category (text), image (src, alt), year, location, duration, area (text), services (services’ slugs), overview, brief, scope, images (exactly four images), result, gallery (images), resultImage |
services |
6 | slug, name, summary, image (src, alt), about, included (text, items: each title, text) |
testimonials |
6 | slug, name, role, photo (src, alt), year (text), rating (a number, 4.9), quote |
team |
12 | slug, name, role, photo (src, alt), summary |
posts |
12 | slug, title, category (Architecture, Construction or Interior), date, excerpt, image (src, alt), content (rich text) |
legal |
2 | slug, title, date, content (rich text) |
- References. A project points to its services by their
slug(services: ["architecture", "interior"]). In the CMS make it a reference to services and return the slugs in your mapping. They give the links of the project’s Services fact, in that order; a slug that matches no service is left out. Testimonials and team members have no pages and nothing refers to them. - Order. Return entries in the CMS’s order with their
position(src/lib/content.tssorts by it), and give the CMS a sort field for the projects, the services, the testimonials, the team and the legal pages: that order is the order of the cards, Home’s first six projects, “Other Work” (the first three others), the services switcher (numbered 01, 02… in that order), the footer’s columns, the testimonials and the team. Posts are sorted bydate, newest first, whatever order they arrive in: Home shows the three newest, and “Similar posts” up to three of the same category. - Ids. Keep each entry’s
idequal to itsslug, assrc/content.config.tsdoes: theget…(slug)functions look entries up by it. Slugs become file names (project/<slug>.html): keep them to lower-case letters, digits and hyphens. - Dates. A post’s and a legal page’s
dateis an ISO date ("2026-05-14"), shown as “May 14, 2026”. A project’syear,durationandareaand a testimonial’syearare plain text. - Fixed counts. A project’s
imagesare exactly four (two tall, two wide, around the story); require four in the CMS. Itsgalleryshows every photo (three in the demo). A service’s deliverables (included.items, five in the demo) may have an emptytext. - Categories. A post’s
categoryis one of three names (postSchemainsrc/content/schemas.ts). Make it a list of options in the CMS, or widen the schema toz.string()if editors may add categories. A project’scategoryis free text. - The sitemap and the footer read the same functions, so new entries are listed once the site rebuilds.
Rich text
Section titled “Rich text”A post’s content and a legal page’s content are lists of blocks, not HTML:
{ type: "paragraph", text: "…" } // **bold**, *italic*, [links](href), "\n" for a line break{ type: "heading", level: 2 | 3 | 4 | 5 | 6, text: "…" } // every level is drawn in the Heading 3 style{ type: "quote", text: "…" }{ type: "list", ordered: false, items: [[{ type: "paragraph", text: "…" }], …] }Convert your CMS’s rich text to these blocks in your mapping, bold as **…**, italics as *…* and links as
text (how). A post’s search description uses the start of
its first paragraph when the excerpt is short, and a legal page’s description is its first paragraph. The other long
texts (a project’s overview, brief, scope and result, a service’s about and included text) are plain strings.
Images
Section titled “Images”Every photo sits in a frame and is cropped to fill it, so a photo of other proportions works; upload images at least as
large as the layout uses, and store an alt for each:
| Image | Size |
|---|---|
A project’s image (the full-screen cover of its page, the cards) |
2400 × 1600 |
A project’s images 1 and 4 (tall, 2 : 3) |
456 × 684 |
A project’s images 2 and 3, gallery and resultImage (1.5 : 1) |
1724 × 1149, 1090 px wide, 2280 × 1520 |
A service’s image (its page, the Services cards, Home’s switcher) |
2280 × 1520 |
A testimonial’s photo (round, 38 px) |
152 × 152 |
A team member’s photo (portrait, 0.74 : 1) |
800 × 1200 |
A post’s image (its page at 1.5 : 1, the cards at 1.9 : 1) |
2280 × 1520 |
A CMS gives full image URLs: the image components (FillImage and Photo in src/design-system/components/media/)
take either a /images/<file> path or a URL (isRemote() and imageUrl() in src/design-system/utils/image.ts). Allow
the CMS’s image host in astro.config.mjs (image.domains) so Astro resizes its photos too
(Images).