---
title: "Type-safe content collections are underrated"
date: 2026-02-03
category: article
tags: ["astro","typescript","content"]
author: "Thomas Kokholm"
url: https://thko.pages.dev/blog/2026/type-safe-content-collections/
---

# Type-safe content collections are underrated

The nicest part of authoring content in this setup is that a typo in the
frontmatter fails the build instead of silently rendering an empty page.

## A schema is documentation

The collection schema describes exactly what a post may contain: a title, a
publish flag, a category, a list of tags, and a date. When I open an old post a
year from now, the schema tells me what is allowed without having to remember.

## Defaults do the boring work

`published` defaults to `false`, so a half-finished draft can sit in the repo
without leaking to the world. Publishing is a one-word diff.
