SESSION / working transcript
Building a custom blog with Astro and Payload
The key decisions behind a self-hosted blog, editable in Payload and fully designed with Astro.
I want a self-hosted blog, one author, no newsletter. I do want analytics, though, and above all something much more configurable than a template-based design. I’d like a terminal style.
Sounds good. I’ll get started right away.
Building
- 01Defining structure
- 02Build home page
- 03Generate article parser
- 04Writing first article
- 05Building CSS style
- 06Deploy and open preview
I really like it. New idea: what if we publish articles as chat sessions, with messages, commands, and tool output? And keep regular blog posts in the same list too? Also, you built me a simple site, but how can I edit my posts easily?
Yes. Both formats can live in the same list. Each entry will simply state its format: a regular article with an editorial body, or a session made up of messages, commands, and tool output. The site will then use the appropriate layout.
For editing, changing Markdown files directly would quickly become cumbersome. We need an interface that can manage drafts, media, metadata, and previews before publication.
Of the available options, Publii seems like the simplest fit for your needs. You could write from a desktop app, fully customize the theme, then generate the site locally and publish it to your server over SFTP.
$ Building demo with PubliiPublii looks convenient, but is it really doing anything for us if we rebuild the entire theme and publishing workflow?
Not really. Publii is very effective at quickly generating a static site from a theme. But if we customize the editorial model, sessions, components, and previews, we’ll probably spend our time working around the way it operates.
Astro would be a better fit: the site would stay lightweight, fast, and mostly static, while giving us control over every detail of the final result.
Okay, let’s go with Astro. But do I lose the admin interface? I want something with drafts, media, and a real preview before publication.
We can separate editing from rendering.
A headless CMS such as Payload or Directus would store the content, versions, drafts, and media. Astro would fetch that data and remain entirely responsible for the public site.
The preview wouldn’t be an approximation inside the CMS: it would open the actual Astro site with the content still in draft.
I prefer Payload; it looks simpler. Build me a local demo.
I’ll create a single collection called “Publications”, with a field that determines the format: article or session.
Both will share the same metadata — title, summary, image, date, status, and URL — while keeping their own structure. Articles will have a rich editorial body. Sessions will be made up of messages, notes, and tool calls.
$ pnpm create astro
✔ Astro project created
$ pnpm create payload-app
✔ Payload project created
✔ PostgreSQL adapter configured
✔ Drafts and versions enabledThe foundation is ready. I’m moving on to the content model and preview.
$ pnpm test:content-model
✔ article publication validated
✔ session publication validated
✔ draft preview token validated
✔ reading time calculatedI love the demo. Let’s deploy it to my server, but reuse the PostgreSQL instance that’s already running. And keep Umami for analytics, protected like the rest of the admin.
I’ll keep the existing PostgreSQL instance. Astro will be the only application exposed publicly. Payload and Umami will remain on subdomains protected by the reverse proxy.
Before deploying, I’ll check the connections, required variables, and backup status without touching the server’s other services.
$ docker compose up -d --build
✔ payload ready
✔ astro ready
✔ postgresql connected
✔ umami healthy
✔ reverse proxy healthyThe deployment is complete. The public site is responding correctly, the admin is protected, and Payload is connected to the existing PostgreSQL instance.