---
title: "Writing Posts for mkblog"
date: 2026-02-27
tags:
  - cli
  - unix
  - markdown
---

`mkblog` accepts ordinary Markdown files from `content/`, but there is one distinction worth making explicit: a post can either include YAML front matter or let the builder infer metadata from the file itself.

The canonical format is still a Markdown file with a front matter block at the top:

```md
---
title: "Hello World"
date: 2026-02-25
tags:
  - freebsd
  - cli
slug: hello-world
draft: false
hidden: false
---

Sample post body.
```

When that block is present, `mkblog` uses it as the source of truth. `title` and `date` are required in explicit front matter. `tags`, `slug`, `draft`, and `hidden` are optional.

Here is what each front matter field means:

- `title`: the human-readable post title shown on the page.
- `date`: the post date used for sorting and archives. It supports `YYYY-MM-DD`, `YYYY-MM-DD HH:MM:SS`, `YYYY-MM-DDTHH:MM:SS`, and full RFC3339 timestamps such as `2026-04-09T14:30:00Z`.
- `tags`: a list of tags used to group posts on tag pages.
- `slug`: the URL name for the post. A post with `slug: hello-world` is published at `/blog/hello-world/`.
- `draft`: when `true`, the post is excluded from normal builds unless you use `--include-drafts`.
- `hidden`: when `true`, the post still gets its own page, but it is omitted from the home page, blog index, tag pages, and archives.

`slug` is especially useful when you want the public URL to stay short or stable even if you rename the file or change the title later.

If you include a time in `date`, `mkblog` uses it for parsing, sorting, future-date checks, and the displayed `HH:MM` value in terminal-style `ls -lta` listings. If the front matter only has a date, the listing falls back to the source file's modification time for `HH:MM`.

Plain Markdown files without front matter also work. In that case `mkblog` keeps the file unchanged and derives metadata during the build:

- `title` comes from the filename
- `slug` comes from the filename
- `date` comes from the file modification time
- `tags` default to an empty list
- `draft` defaults to `false`
- `hidden` defaults to `false`

For example, a file at `content/ssh-notes.md` with no front matter will build as a post titled `Ssh Notes` at `/blog/ssh-notes/`.

That behavior is meant to make quick notes and imported Markdown easier to publish without forcing a metadata header into every file. It does not rewrite the source file for you. If you later want cleaner titles, stable dates, tags, or a custom slug, add a front matter block explicitly.

There are two built-in visibility controls for explicit front matter:

```md
---
title: "Work In Progress"
date: 2026-04-09
draft: true
---

This post will not appear in a normal build.
```

`draft: true` is for in-progress posts. A normal `mkblog build` excludes them entirely. They only show up if you build or serve with `--include-drafts`.

```md
---
title: "Unlisted Notes"
date: 2026-04-09
hidden: true
tags:
  - notes
---

This post still gets its own page, but it is omitted from listings.
```

`hidden: true` is for direct-URL posts. `mkblog` still generates the page itself, but leaves it out of the home page, the main blog listing, tag pages, and archive pages. That makes it suitable for notes you want to publish without advertising in the main index.

Malformed front matter still stops the build. That is intentional. If a file starts with `---`, `mkblog` assumes you are declaring metadata on purpose and validates it instead of guessing.

The rest of the content layout is straightforward:

```text
content/
  *.md
  files/
  casts/
  snippets/
```

Posts live in `content/`. Additional downloadable files go in `content/files/`. Asciinema cast files live in `content/casts/`, and source snippets used by the `source` shortcode live in `content/snippets/`.

That keeps the workflow close to the filesystem: write a Markdown file, run the build, and ship the generated site.
