The following text is partly by Claude Code.

This blog consists of a single Zig program. It reads Markdown files from a folder and serves them as HTML – similar to the flat-file CMS Grav, only smaller.

Life of a request #

The browser asks the Zig server, which reads Markdown files and answers with HTML
Life of a request

On every request the server reads the content tree anew. A change is therefore visible immediately, and there is no cache you could forget to clear.

The folder structure is the page structure #

content/
content/
├── index.md                  → /
├── index.en.md               → /en/
├── 01.blog/
│   ├── index.md              → /blog/
│   └── hallo-zig/
│       ├── index.md          → /blog/hallo-zig/
│       ├── index.en.md       → /en/blog/hallo-zig/
│       ├── ablauf.svg        → /blog/hallo-zig/ablauf.svg
│       └── demo.mp4          → /blog/hallo-zig/demo.mp4
└── 02.ueber/
    └── index.md              → /ueber/

A few rules are enough:

  1. A folder with index.md is a page.
  2. A number prefix like 01. sets the order and adds the page to the navigation. It does not appear in the URL.
  3. Images and videos live next to the Markdown file and are included with relative paths.
  4. A translation sits next to the original and carries the language code in its name: index.en.md.

Code #

Code blocks are highlighted on the server, so no JavaScript is needed. This is the loop that accepts new connections:

src/server.zig
pub fn run(self: *const Server, listener: *net.Server) void {
    var group: Io.Group = .init;
    defer group.cancel(self.io);

    while (true) {
        const stream = listener.accept(self.io) catch return;
        // Every connection gets its own task.
        group.concurrent(self.io, handleConnection, .{ self, stream }) catch {
            stream.close(self.io);
        };
    }
}

Building and starting works with the Zig build system:

zig build run -- --port 8080

Videos #

Videos are included like images; the file extension decides whether you get an <img> or a <video>. The server supports range requests for this, so you can seek within the video.

A Mandelbrot zoom, created with ffmpeg

Summary #

Building blockImplementation
ServerZig 0.17, std.http.Server
ContentMarkdown with frontmatter
DesignOne stylesheet, light and dark mode
HierarchyFolder structure
Languagesindex.md, index.en.md, …

Little technology, little maintenance: one binary, one folder of text files.