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?)
- I don’t want to write HTML if I can help it
- I don’t want to write code if I can help it
- Markdown is fine
- Plaintext (mostly), monospace fonts (mostly)
- I do like pretty pictures and want those to work
- Everything should be static
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:
- Check to see if there’s a Markdown H1 on the first line. That’s the page title.
- Convert the Markdown to HTML via
- Wrap the content of the .md file in an
<article>tag (to make styling easier).
- 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.
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.
- Write in org-mode (using org-mode syntax)
- Export with
C-c C-e m o
- Clean up extra whitespace (immediately after headers, usually)
- Move the
.mdfile into the right spot
- 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.