🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
CMS & Integrations••By Komal Nakrani

What Is a Headless CMS? How It Works With Astro

What a headless CMS is, how it differs from a traditional CMS, API-based vs Git-based options, pros and cons, and how a headless CMS connects to an Astro website.

#Astro#Headless CMS#CMS#Content

A headless CMS is a content management system that stores and edits content but doesn’t render your website. Editors write in the CMS’s interface, the content is saved as structured data, and your site fetches it through an API (or reads it from Git) and builds the pages itself. “Headless” means the front end, the “head”, is removed: you choose any framework, such as Astro, to display the content.

This explainer covers how a headless CMS works, how it compares with a traditional CMS like WordPress, the main types, when one is worth it, and how it plugs into an Astro site.

Key Takeaways

  • A headless CMS handles content editing and storage; your code handles presentation.
  • Content is delivered as structured data through an API, or as files in a Git repository.
  • API-based options include Sanity, Contentful, Storyblok and Strapi; Git-based options include Decap, Keystatic and TinaCMS.
  • Benefits: any front end, reuse across channels, better performance and security. Costs: more setup, and previews take work.
  • Astro fetches headless CMS content at build time, so visitors get static HTML with no CMS code.

Traditional CMS vs headless CMS

A traditional CMS like WordPress, Drupal or Joomla is a monolith. One system stores content in a database, provides the editing interface, and renders pages through its own theme layer on every request (or from a cache).

A headless CMS keeps only the first two jobs:

Traditional CMS Headless CMS
Content storage Database inside the CMS CMS database or Git repository
Editing interface Yes Yes
Renders the website Yes, through its themes No, your front end does
Delivers content As finished HTML pages As JSON over an API, or as files
Front-end choice The CMS’s theme system Any framework or language
Hosting Server with PHP and a database Front end on any host; CMS hosted by vendor or you
Channels Mostly one website Website, apps, email, signage from one source

Because the CMS and the site are separate, each can change independently. You can redesign the site without migrating content, or switch CMS without rebuilding the front end, as long as the data shape stays the same.

How a headless CMS works

  1. Model the content. You define content types and fields: a “post” has a title, slug, date, author reference, hero image and rich-text body. This is the schema editors fill in.
  2. Editors create entries. They write in a web interface with forms, rich-text editors and media libraries, without touching code.
  3. The CMS stores structured data. Rich text is stored as structured JSON or Markdown rather than as page HTML, so it can be rendered anywhere.
  4. Your site requests content. At build time or per request, the front end queries the CMS’s REST or GraphQL API (or reads files from the repo).
  5. Your site renders pages. Templates turn the data into HTML.
  6. Publishing triggers an update. A webhook tells your host to rebuild, or on-demand pages fetch fresh data.

Types of headless CMS

API-based (hosted or self-hosted)

Content lives in the CMS’s own database and is served through an API.

  • Hosted SaaS: Sanity, Contentful, Storyblok, Hygraph, Prismic. No server to run; pricing is usually based on users, records or API usage.
  • Self-hosted open source: Strapi, Directus, Payload. You run the CMS on your own server and database, with no per-seat fees but with maintenance.

These suit larger teams, structured content reused across many pages or channels, and editors who need features like scheduling, roles, localization and visual editing.

Git-based

Content is stored as Markdown, MDX, JSON or YAML files in your repository. The CMS is an editing interface that commits changes to Git.

  • Examples: Decap CMS, Keystatic, TinaCMS, Pages CMS.
  • Strengths: content is versioned with code, there’s no extra database, and the site builds exactly as it does locally.
  • Limits: fewer workflow features, and every save becomes a commit and a rebuild.

These suit small teams, developer-led sites, and content that already lives in Markdown. The Astro Decap CMS guide shows one end to end.

Benefits of a headless CMS

  • Front-end freedom. Use the framework that fits the site, not the one the CMS dictates.
  • Performance. Pages can be prebuilt as static HTML, served from a CDN, with no CMS code running per request.
  • Security. The public site has no admin login or database exposed. The CMS lives on a separate domain or vendor.
  • Reuse. One piece of content feeds the website, a mobile app and a newsletter.
  • Editor experience. Structured fields keep content consistent, and modern editors offer collaboration, previews and scheduling.

Drawbacks and costs

  • More moving parts. A traditional CMS is one install. Headless means a CMS, a front end, a host and the glue between them.
  • Previews take work. Editors expect to see their page before publishing. With a headless CMS, you build a preview mode or deployment.
  • Pricing. Hosted plans can grow with seats, locales or API calls. Check limits before committing.
  • No themes or plugins in the CMS. Features a WordPress plugin gives you instantly (forms, SEO fields, galleries) are built in the front end or with services.
  • Content modeling up front. Good schemas take thought; bad ones are painful to change later.

When you don’t need a headless CMS

Plenty of sites are better without one. If the people editing content are developers, or content changes a few times a month, Markdown files in Git are simpler, free, and versioned automatically. Astro’s content collections give those files a typed schema, so a missing field fails the build rather than breaking a page. The Markdown or CMS decision guide walks through the trade-off.

A headless CMS earns its place when non-technical editors publish often, content is reused across many pages or channels, or you need roles, approvals, scheduling or localization.

How a headless CMS connects to Astro

Astro fetches content in server code, usually at build time, and renders it to HTML. There are two common patterns.

Fetch in the page. Call the CMS API in a page’s frontmatter or in getStaticPaths():

---
// src/pages/blog/[slug].astro
export async function getStaticPaths() {
  const res = await fetch('https://cms.example.com/api/posts?fields=title,slug,body', {
    headers: { Authorization: `Bearer ${import.meta.env.CMS_TOKEN}` },
  });
  const posts = await res.json();
  return posts.map((post) => ({ params: { slug: post.slug }, props: { post } }));
}

const { post } = Astro.props;
---
<article>
  <h1>{post.title}</h1>
  <div set:html={post.body} />
</article>

Load into a content collection. A content loader pulls CMS entries into a collection, so pages use getCollection() exactly as they would with local Markdown, and Astro validates the data with your schema:

// src/content.config.ts
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';

const posts = defineCollection({
  loader: async () => {
    const res = await fetch('https://cms.example.com/api/posts');
    const data = await res.json();
    return data.map((post) => ({ id: post.slug, ...post }));
  },
  schema: z.object({
    title: z.string(),
    body: z.string(),
    publishedAt: z.coerce.date(),
  }),
});

export const collections = { posts };

Many CMSs publish official Astro integrations or loaders that handle authentication, rich text and images for you. The headless CMS guide for Astro compares the popular options, and the content collections guide explains loaders and schemas.

To keep a static site current, add a webhook in the CMS that calls your host’s deploy hook on publish. For pages that must show changes instantly, render those routes on demand with an adapter.

Choosing a headless CMS for an Astro site

You need Consider
Free, content in Git, developer-friendly Decap CMS, Keystatic, TinaCMS
Visual, drag-and-drop page building for marketers Storyblok
Highly structured content and custom editing UI Sanity
Enterprise workflows and many locales Contentful, Hygraph
Self-hosted, own your data, no per-seat fees Strapi, Directus, Payload

Komal themes keep their content in local Astro content collections, which means they work without any CMS and can be connected to one later by swapping the data source behind getCollection(). Themes in the Blog & Editorial category are the most common starting point for CMS-driven sites. Astro’s CMS guides list official setup instructions for dozens of headless CMSs.

FAQ

What is a headless CMS in simple terms?

It’s a content management system without a built-in website. Editors manage content in it, and a separate website or app fetches that content through an API and decides how to display it.

Is WordPress a headless CMS?

Not by default; WordPress renders its own themes. It can be used headlessly through its REST API or a GraphQL plugin, with a separate front end such as Astro displaying the content.

What is the difference between a headless CMS and a static site generator?

A headless CMS stores and edits content. A static site generator turns content and templates into HTML files. They’re often used together: the CMS supplies content, and the generator, such as Astro, builds the pages.

Is a headless CMS good for SEO?

It can be very good, because the front end can prerender fast, complete HTML pages. SEO depends on that front end: titles, meta descriptions, structured data and URLs must be rendered by your site, often from fields you add to the CMS schema.

Do I need a headless CMS for an Astro website?

No. Astro reads Markdown and MDX from your repository with typed content collections. Add a headless CMS when non-technical editors need to publish often or content must be shared across channels.