It's not you, it's me

A Static Nonsense Generator

I done redone the blog.

I got tired of trying to futz with other people’s systems to make my blog the way I want it. So I programmered the shit out some computers and now I have my own terrible system.

(I know what you’re thinking: this is the site you want?)

The Requirements

The A Solution

A bash script that kind-of-but-not-really translates Markdown files into a static HTML site.

I tried pandoc first, but almost immediately ran afoul of it requiring half a GB (!) worth of Haskell to work. When I did get it running I couldn’t figure out how to get it to stop aggressively replacing everything with HTML entities.

The next pass was just straight up converting Markdown to HTML via various CLI utilities. Almost all of these felt heavy handed, but I landed on mdtohtml since it was easy to compile (yay Go binaries).

The next step is “decorating” the converted HTML. More or less adding a title and a style tag. Easy enough with some bash magic.

Here’s how it works. For every .md file in my “blog” directory:

  1. Check to see if there’s a Markdown H1 on the first line. That’s the page title.
  2. Convert the Markdown to HTML via mdtohtml.
  3. Wrap the content of the .md file in an <article> tag (to make styling easier).
  4. Add a header that includes a small stylesheet, the title, and the banner.

And that’s it. It’s ended up being simple - the bash script is about 40 lines.

It’s not perfect, naturally. I have to manually build the index.html page when I write something, for example. All in all, I’m okay with it…but even if I’m not, I can change it later. It may be hammer, but it’s a hammer that fits my hand perfectly.

Update: org-mode

For lots of reasons I decided to move back to org-mode for my blog writing. Helpfully, it has a Markdown exporter. The flow is a little manual but I do like having everything in Markdown syntax.

  1. Write in org-mode (using org-mode syntax)
  2. Export with C-c C-e m o
  3. Clean up extra whitespace (immediately after headers, usually)
  4. Move the .md file into the right spot
  5. Run the above bash script

I think the next step is to have emacs just do steps 3-5 after the export. But that’s for another day.