tutorial March 15, 2026 1 min read

Using Cloudflare D1 as a Multi-Site CMS Database

How to use Cloudflare D1 as the database backend for a multi-site CMS. Schema design, content management, and edge performance.

0

Cloudflare D1 is a serverless SQLite database that runs at the edge. It is perfect for content management systems because reads are fast (local to the Worker) and the data model maps naturally to CMS concepts.

Why D1 for a CMS?

Traditional CMS platforms use PostgreSQL or MySQL hosted in a single region. Every page render requires a cross-network database call. With D1, your database is co-located with your compute at the edge — reads complete in single-digit milliseconds.

D1 also has a generous free tier: 5GB storage, 5M rows read/day, and 100K rows written/day. For a content site portfolio, this is effectively free.

Schema Design

The core tables for a multi-site CMS are straightforward:

  • sites — One row per site. Stores domain, brand, template, theme colors, feature flags.
  • blog_posts — Content with site_id foreign key. Slug, title, HTML content, author, category, tags, SEO keyword.
  • directory_entries — Curated listings with name, description, URL, rating, affiliate link.
  • pages — Custom content pages (about, privacy, etc.)
  • homepage_sections — Ordered sections for each site homepage. Section type + JSON config.

Content API

With Hono on Workers, building the API is clean. Each endpoint is scoped by site_id. Blog posts, directory entries, and pages all follow the same pattern: list (GET), create (POST), update (PUT), delete (DELETE). Validation with Zod ensures data integrity.

Performance in Practice

A typical page render requires 2-3 D1 queries: site config, page content, and navigation links. With D1 read replication, these complete in 1-5ms each. The entire render pipeline — database reads, template rendering, and HTML generation — typically completes in under 50ms.

Content Management Workflow

Content enters the system through multiple channels: direct API calls from a dashboard, queue-based batch processing from content pipelines, or manual creation through the admin interface. All content is immediately live — no build step required.

Migration from WordPress

Moving from WordPress to a D1-backed CMS means exporting your posts as JSON, mapping WordPress categories/tags to your schema, and inserting via the API. The content itself (HTML) transfers directly. What you lose: plugins. What you gain: 10x faster page loads and zero server maintenance.

Was this article helpful? Thanks for your feedback!
cloudflared1databasecmsedge

Enjoyed this article?

Get more insights like this delivered to your inbox.

? shortcuts·⌘K search