- HTML 69%
- Go 31%
- Makefile <1%
mfblog #
A tiny static blog generator in the spirit of the modern motherfucking website.
You write markdown. It outputs one self-contained semantic HTML file per page. No database, no JavaScript, no bundler, no lockfile. A single Go binary with two dependencies — goldmark for markdown and chroma for build-time syntax highlighting.
Quick start #
go build -o mfblog .
# (devel) binary; to stamp it with the git commit like the Makefile does:
# go build -ldflags "-X mfblog/internal/version.Version=$(git rev-parse --short HEAD)" -o mfblog .
# dev loop: edit a file, refresh the browser
./mfblog serve -dir site
# production build
./mfblog build -dir site
# → site/out/ — deploy is "copy that directory to the served directory"
# cross-compiled release binaries (win/linux/macos × amd64/arm64) into dist/
make # or: make linux-arm64, make macos-aarch64, ...
mfblog -version # print the build's git commit (the Makefile stamps it)
mfblog -help # full help: every subcommand and all of its flags
# (each subcommand also takes -h)
Starting from scratch:
./mfblog createsite -dir mysite # scaffold config.json + content/ (starter post + legal pages)
cd mysite
mfblog create # write your first real post
mfblog validate # check it before you build
mfblog serve # open http://localhost:8080
Site layout #
my-site/
├── config.json optional; all fields have defaults
├── content/
│ ├── index.md optional home page intro (not a post)
│ ├── 2025-09-01-hello-world.md
│ ├── 2025-09-15-modern-html.md
│ ├── imprint.md a page (type: page): own URL, not listed as a post
│ └── img/ images, referenced as 
└── static/ optional; copied verbatim to the output root
config.json:
{
"title": "My Blog",
"url": "https://example.com",
"description": "A tiny blog.",
"author": "Jane Doe",
"lang": "en",
"dateFormat": "YYYY-MM-DD",
"out": "out",
"homePosts": 10,
"homeCards": false,
"feedPosts": 20,
"docs": false,
"footerLinks": [
{ "text": "Imprint", "href": "/imprint/" },
{ "text": "Privacy Policy", "href": "/privacy-policy/" }
]
}
homePosts — how many posts the home page lists before linking to
/archive/ (default 10). homeCards — when true, the home page renders
those posts as a grid of cards (title, description, date) instead of a
plain list of links (default false). feedPosts — how many posts the RSS,
Atom and JSON feeds include (default 20). docs — when true, the site is
rendered as a documentation site instead of a blog (two-column layout,
ordered pages, no blog surfaces); see Documentation sites. footerLinks — optional {text, href}
pairs rendered in the site footer after the home link: /… hrefs are
internal (they get the base path), scheme URLs (https://, mailto:, …)
open in a new tab, entries with an empty text or href are dropped, and
without the field the footer is unchanged.
url also sets the base path: its path component is the directory the
site is served from. "url": "https://example.com/blog" puts every internal
link, image and feed under /blog/, and mfblog serve hosts the site at
http://localhost:8080/blog/ to match. A bare host
("url": "https://example.com") means the site sits at the domain root.
dateFormat sets how post dates are rendered in human-readable places
(post date line, home list/cards, archive, tag pages): the tokens YYYY,
MM, DD are replaced by year, month and day, everything else is kept
verbatim — "DD.MM.YYYY" is the common European form, "DD/MM/YYYY" and
"YYYY/MM/DD" work too, and "YYYY-MM-DD" (the default) is the ISO form.
Machine-readable dates are protocol, not style: the datetime attributes,
feeds, sitemap and JSON-LD always stay ISO 8601.
lang serves two purposes: the lang attribute of every page (and the
feeds), and the language of the generator's own UI strings — the header
nav, the home/archive/tags headings and empty states, the 404 page, the
table-of-contents label, the draft banner. String files live in the source
under internal/i18n/locales/ (one JSON per language, embedded in the
binary): the current set is English plus the EU official languages
(de, fr, es, it, pt, nl, pl, cs, sk, sl, sv, da,
fi, hu, ro, el, hr, bg, et, lv, lt, ga, mt). An
unknown language — or a missing key — falls back to English, so a
half-translated file never renders blank. To add a language, copy
en.json, translate it, done; tests check that every locale carries
exactly the English key set and that the count strings keep their %d
placeholder. The count strings use a label form (Posts: 4, Posty: 4)
so no language needs plural-case machinery.
Frontmatter #
---
title: Hello world # fallback: first `# heading`, then filename
date: 2025-09-29 # fallback: YYYY-MM-DD filename prefix, then file mtime
description: One line # feeds <meta name=description>, OG and JSON-LD
tags: [go, web] # or a "- item" list; shown under the title
slug: custom-path # optional; default: filename without date prefix
draft: true # optional; skipped in the built site; mfblog serve
# lists it under /drafts/ and previews it with a banner
type: page # optional; makes the document a page, not a post
toc: true # optional; table of contents from h2/h3 headings
# (toc: disclosure renders it as a collapsible box)
---
Body markdown here. The title is rendered by the generator —
do not repeat it as `# heading` in the body.
File names of the form YYYY-MM-DD-slug.md are recommended: the date feeds
the post list and the URL is /slug/.
Pages #
A document with type: page in the frontmatter is a page: it gets its own
/slug/ page — title as the heading, no date line, no tags, no
BlogPosting JSON-LD — but it is not a post: it does not appear in the
home post list, /archive/, the tag pages or the feeds. The sitemap still
lists it; a page without an explicit date gets no <lastmod>. An absent
type or type: post means post (so existing sites keep building
unchanged); any other value is an error. mfblog createsite scaffolds an
imprint.md and a privacy-policy.md page and links both from the footer
via footerLinks. See
2026-10-28-pages-and-footer-links
on the showcase site for a working example.
Drafts #
A document with draft: true is skipped by mfblog build: it is not in
the home post list, /archive/, the tag pages or the feeds, and its page
is not written to out/. To preview it, run mfblog serve and open
/drafts/ — a drafts-only page (styled like the archive, grouped by
year) that lists every draft and links to its preview. While serving, a
Drafts link in the header nav points to it, between Posts and
Archive. Both the link and the page exist only under mfblog serve; the
built site never contains either. The draft URL includes the base path if
your url has one (for the showcase site that is
http://localhost:8080/mfblog/<slug>/), and served drafts are rendered
with a banner that makes clear they are not published. Remove draft: true
to publish the post. The showcase site ships with a permanent draft
("This post is a draft") so the feature is demoable: mfblog serve -dir site, then open /mfblog/drafts/.
What the generator puts in your HTML #
Every page is a full document with:
- semantic landmarks —
<header>,<nav>,<main>,<article>,<time datetime>,<footer> - JSON-LD in the
<head>—BlogPostingon posts,Blogon the index - Open Graph + Twitter meta —
og:title,og:description,og:url,og:typeandtwitter:card - canonical link
- feed discovery —
rel="alternate"links to/rss.xml,/atom.xmland/feed.jsonon every page, so feed readers find them automatically - sticky header — the site header stays at the top while the page
scrolls under it (
position: sticky, no JS) - stylesheet inlined — one
max-width, native CSS nesting,clamp()for the type scale - theme switcher, CSS only — follows
prefers-color-schemeby default; a visually hidden checkbox in the body flips the theme via:has()(icon in the header shows the theme you get on click). No JavaScript, so the flip doesn't survive navigation — each page starts from the system preference - speculation rules for instant navigations — a script tag with JSON in
it, ignored by browsers that don't support it (the only
<script>on the page, and it is data, not code) - sitemap.xml and robots.txt
- images: local
img/files are copied to the output, referenced with absolute URLs, givenwidth/heightread from the file (no layout shift),loading="lazy" decoding="async"after the first one, and the first image is preloaded withfetchpriority="high" - external links get
target="_blank" rel="noopener"
Markdown may contain raw HTML — that is the point. <picture> for AVIF/WebP
format negotiation, <details>, <table>, whatever the platform already
ships.
Archive and feeds #
For when the post list outgrows one screen:
- the home page lists only the
homePostsnewest posts; when truncated it ends with an "All posts (N)" link, and the header nav has a permanentArchivelink /archive/is the whole blog on one page — every post grouped by year, newest first, with a year nav you can jump to (/archive/#2024)/tags/lists every tag with its post count;/tags/<tag>/lists the posts carrying that tag, newest first. Frontmatter tags are normalized for URLs (lowercased, spaces become hyphens), and post pages link from each tag to its page/rss.xml(RSS 2.0),/atom.xml(Atom 1.0) and/feed.json(JSON Feed 1.1, https://jsonfeed.org) carry thefeedPostsnewest posts with full post HTML (RSScontent:encoded, Atom<content type="html">, JSONcontent_html), the frontmatter description, and per-post dates
All three feeds are written on every build and served live by
mfblog serve, so the dev loop applies to them too.
Documentation sites #
mfblog can generate a documentation site instead of a blog: set
"docs": true in config.json. The generator then renders every page in a
two-column layout that fills the screen — the documentation page tree on the
left (sticky, with the current page marked, a thin rule separating the
columns), the content on the right — and adds prev/next page links at the foot of
each page. Above the page title sits a breadcrumb (Home › … › page,
derived from the coordinate's prefixes — no extra metadata), and the
foot links let readers walk the pages in order. No JavaScript; the layout
is CSS grid, the content column keeps a readable width on very wide
monitors, and the active mark is set at build time.
A docs site is built from type: page documents, ordered by a dotted
coordinate prefix that is the page tree:
content/
├── index.md the docs home (shown at the site root)
├── 1-intro.md top-level page → /intro/
├── 1.1-first.md a subpage → /first/
├── 1.2-second.md a subpage → /second/
└── 2-writing-posts.md top-level page → /writing-posts/
A page's parent is its own coordinate without the last component
(1.1 lives under 1) — no parent: field, nothing to keep in sync.
The coordinate is order metadata, not identity: it is stripped from the
URL (1.1-first.md → /first/) and not shown in the list; indentation
carries the structure. Two rules keep the tree sound:
- the tree must be complete —
1.1-x.mdwithout a1-x.mdpage is a hard build error, so a typo in a prefix fails the build instead of silently reshuffling the sidebar - the coordinate is a sort key, not a dense sequence — gaps are legal
(
1, 2, 10), and1.5-…can be added later without renaming
Ordering is numeric per component (1.2 sorts before 1.10, no
zero-padding needed); a parent always sorts before its children, which is
the reading order the prev/next links follow. Pages without a prefix sort
after the numbered ones. The slug: frontmatter override still works.
Because the purpose is different, a docs site drops the blog surfaces:
no latest-posts list on the home, no /archive/, no tag pages, no
RSS/Atom/JSON feeds and no Blog JSON-LD (the <link rel=alternate> feed
links are omitted too). The sitemap, 404 page, favicon, static/, img/
and the theme switcher all remain. mfblog serve 404s the blog routes on a
docs site to match, and mfblog validate warns about dated post files
(dated posts are still built, but nothing links to them).
The per-page table of contents is a natural fit for docs — toc: disclosure
reads well in the narrow content column. Sidebar labels ("Home"), the
prev/next links and the aria labels are localised like the rest of the UI
chrome.
Drafts fit the layout too: mfblog serve on a docs site lists draft pages
at the end of the sidebar, marked [DRAFT], and previews them with the
usual banner — the /drafts/ list page (a blog feature) 404s instead. The
mark is localised; build never shows it, so the written site has no trace
of drafts.
The repo carries a working example in site-docs/ (this very document's
source): mfblog serve -dir site-docs hosts it at
http://localhost:8080/mfblog-docs/. mfblog createsite -docs (or
"yes" to the "Documentation site" prompt) scaffolds a bare-bones docs site:
a config with "docs": true, an index.md and two numbered starter pages.
Components #
Carousel (CSS only) #
The stylesheet ships a carousel built on scroll snapping and anchor
links — no JavaScript. In markdown you write a small fence block instead
of the HTML: one  line per slide, plus an optional quoted
caption on the opening line.
:::carousel "optional caption"



:::
mfblog expands that to the full <figure class="carousel"> markup, with
generated slide ids (c1-s1, c1-s2, …) and the matching thumbnail links —
nothing to keep in sync by hand. Multiple carousels on one page are fine.
A line that is not  inside the block is a build error.
The generated HTML, for reference (it also works to paste it directly — raw HTML in markdown is a feature):
<figure class="carousel">
<div class="carousel__gallery" tabindex="0">
<img class="carousel__slide" id="c1-s1" src="img/a.jpg" alt="First">
<img class="carousel__slide" id="c1-s2" src="img/b.jpg" alt="Second">
<img class="carousel__slide" id="c1-s3" src="img/c.jpg" alt="Third">
</div>
<nav class="carousel__thumbs" aria-label="Carousel images">
<a href="#c1-s1" aria-label="Show First"><img src="img/a.jpg" alt=""></a>
<a href="#c1-s2" aria-label="Show Second"><img src="img/b.jpg" alt=""></a>
<a href="#c1-s3" aria-label="Show Third"><img src="img/c.jpg" alt=""></a>
</nav>
<figcaption>optional caption</figcaption>
</figure>
Each slide fills the gallery width; the row of thumbnails below is both
the navigation and the indicator that there is more to see. Swiping
advances one slide at a time (scroll-snap-type: x mandatory +
scroll-snap-stop: always), scrollbars work natively, and the thumbnails
are plain href="#id" links — the browser does the smooth scroll. Note:
fragment navigation scrolls every scrollable ancestor, so clicking a
thumbnail also scrolls the page to the carousel (that's inherent to the
CSS-only approach; isolating the horizontal jump would need JS). Keep
alt="" on the thumbs so assistive tech reads the gallery once. See
site/content/2026-09-08-carousel-without-javascript.md for a working
example.
Cards #
For a shelf of things you point people at (tools, gear, books), write a
:::cards fence: one * Name line per card, then optional indented
fields — image, alt, desc, price, url.
:::cards
* Desk Mat
image: img/desk-mat.png
desc: The surface your keyboard lives on.
url: https://example.com/desk-mat
* Monitor Light
image: img/monitor-light.png
desc: Light where you work, not where you sit.
url: https://example.com/monitor-light
:::
mfblog expands that to a responsive <ul class="cards"> grid of cards
(auto-fill columns, so the grid reflows from 3-up to 1-up with no media
queries). Every field except the name is optional; a card without a url
is just a card, and the image alt falls back to the card's name. A card
with a url is one link — the whole card, not just the title, is
clickable and keyboard-reachable — and that link gets
target="_blank" rel="noopener" automatically. Card images get the same
treatment as every other image (absolute URL, real width/height, lazy
after the first). Unknown fields and fields before the first * Name line
are build errors. See
site/content/2026-09-15-cards.md for a working example.
Disclosure (browser native, no JavaScript) #
For an expand/collapse section — an explanation, a changelog, an FAQ answer —
write a :::disclosure fence. An optional quoted summary goes on the opening
line, the body is ordinary markdown, and ::: closes it:
:::disclosure "Click to reveal"
The body is markdown, so emphasis, links, lists and code all work inside it.
:::
mfblog compiles that to the browser's native <details>/<summary> widget with
the body rendered as markdown. The open/closed state is the browser's and the
styling is CSS, so there is no JavaScript. The summary is optional — a bare :::disclosure
line opens an unlabelled disclosure. Because the body is markdown, a
:::cards or :::carousel fence nests inside a disclosure (the inner fence
is expanded first). A disclosure is the outermost fence — it can't nest inside
another disclosure or inside a card. See
site/content/2026-09-26-disclosure-without-javascript.md for a working
example.
Table of contents (build time, no JavaScript) #
A document with toc: true gets a table of contents above its body,
generated at build time from the h2 and h3 headings in its markdown:
h3s nest under the h2 that precedes them. The links point at the ids
goldmark generates for the headings, so anchors land exactly on the
heading — and the sticky header already leaves room (scroll-margin-top)
so jumps don't land under it. If the document has no h2/h3 headings,
nothing is rendered. h1 (the title is one) and deeper headings are not
listed, and hand-written headings without an id are skipped, since they
have no anchor.
There are two styles: toc: true (the default) renders the ruled
contents box, always visible; toc: disclosure renders the same entries
as a native <details>/<summary> disclosure, collapsed until clicked —
the browser does the toggle, no JavaScript. Any other value is a build
error. See
site/content/2026-10-29-toc-without-javascript.md for a working example.
Footnotes (CSS only) #
Standard markdown footnotes — a [^name] in the text and a
[^name]: note definition after it — render as a superscript link in the
text and a notes block at the bottom of the post. Clicking a reference
jumps to the note; the backref arrow jumps back. Note bodies are ordinary
markdown (emphasis, links, lists, code). An undefined reference is left
as literal text so you notice it. No JavaScript — both directions are
plain anchor links. See the "Footnotes" section of
site/content/2026-09-29-markdown-basics.md for a working example.
Syntax highlighting (build time, no JavaScript) #
Fenced code blocks are coloured at build time by
chroma — the generator tokenises the
block and wraps each token in a <span>, so the page itself stays
JavaScript-free and the colours come from the inlined stylesheet (they follow
the theme switcher, light and dark).
const maxRetries = 3 // how many times to try
func main() {
// greet, then report the retry budget
fmt.Printf("hello, mfblog (retries: %d)\n", maxRetries)
}
The language comes from the fence tag (go, bash, json, …). Any language
chroma knows works; a fence whose language chroma doesn't recognise is left
plain, and a languageless fence is never highlighted.
Commands #
mfblog build [-dir <site dir>]
build to <site dir>/out
mfblog serve [-dir <site dir>] [-addr :8080]
local server; pages render fresh on every request,
so the dev loop is save + refresh. Hosts under the url
base path if it has one (http://localhost:8080/blog/).
Drafts are previewed here with a banner; they are never
part of the built site
mfblog create [-dir <site dir>]
interactively scaffold a new post: it asks for the
frontmatter (title, description, tags, draft, table of
contents as box or disclosure) and the slug, and stamps
today's date into the filename for you
mfblog createsite [-dir <site dir>] [-title T] [-url U] [-description D]
[-author A] [-docs]
scaffold a whole new site (config.json, content/ with a
starter post plus default imprint and privacy policy
pages, img/ and static/); the config links both pages
from the footer. Interactive by default; passing any of
the value flags skips the prompts (non-interactive, for
scripts/CI), unset values keep their defaults. With
-docs it scaffolds a documentation site instead: a
config with "docs": true, an index.md and two numbered
starter pages (no imprint/privacy, no dated post)
mfblog validate [-dir <site dir>]
check the site without building: duplicate slugs, slugs that
collide with generator pages, posts that fail to render, and
missing images. Exits non-zero if anything is an error
Design rules #
- start with HTML, add what you need, stop when you're done
- a "feature" that the browser already ships is not a reason for a dependency
- the output must be readable top to bottom by a human in a text editor
- every byte in the output is there because the author chose it
Development #
go build -o mfblog .
go test ./... # frontmatter, rendering, build output, serve handlers
License #
MIT — see LICENCE.