Skip to content
Sign inJoin waitlist

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.

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.ts sorts 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 by date, 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 id equal to its slug, as src/content.config.ts does: the get…(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 date is an ISO date ("2026-05-14"), shown as “May 14, 2026”. A project’s year, duration and area and a testimonial’s year are plain text.
  • Fixed counts. A project’s images are exactly four (two tall, two wide, around the story); require four in the CMS. Its gallery shows every photo (three in the demo). A service’s deliverables (included.items, five in the demo) may have an empty text.
  • Categories. A post’s category is one of three names (postSchema in src/content/schemas.ts). Make it a list of options in the CMS, or widen the schema to z.string() if editors may add categories. A project’s category is free text.
  • The sitemap and the footer read the same functions, so new entries are listed once the site rebuilds.

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.

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).