diy blog site generator tool thing

ok i caved and used pandoc to build my site

I said, proudly, in my previous post that this site is just pure html and it doesn't use any build systems and i'll forget to add the header one day and i won't care.

Well, uh, yeah I lied. I didn't like writing in HTML and wanted to write in Markdown. It's a lot nicer to read, and doesn't make my fingers strain from typing <p> tags all over the place.

I still didn't want to set up some over-the-top complicated build system though, so I kinda just wrote a little script. And it's (almost) a one-liner too:

#!/usr/bin/env bash

rm ../blog/*.draft.html &> /dev/null
parallel --bar --eta --jobs 4 \
  pandoc {} -f gfm -t html \
    --standalone \
    --template ../misc/post-template.html \
    --highlight-style breezedark \
  \| prettier \
    --parser html \
    --prose-wrap always \
  \> ../blog/{/.}.html \
  ::: ../*.md

So as it turns out, pandoc is quite a powerful tool. I thought it was just for converting things between formats, but turns out it has things like syntax highlighting and a templating engine. Which is great because I can have pretty code blocks without having to rely on javascript.

Also I piped the output from pandoc to prettier so you can read the page's source code without straining your eyes. The benefits of minifying html is minimal anyway when the page is compressed in transit.

rss feeds

Of course I didn't stop there. Might as well add an RSS feed for my blog! I put together a few more lines in the build script, also using pandoc, to generate the xml file:

echo 'Generating RSS feed...'

cat <<EOF > $rss_temp
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="">
    <title>kitsune&#8217;s blog</title>
    <description>join me as i write about random stuff on my mind</description>
    <lastBuildDate>$(date -R)</lastBuildDate>
    <atom:link href="$baseurl/blog/rss.xml" rel="self" type="application/rss+xml" />

for f in ../*.md; do
  slug=$(basename "$f" .md)
  postdate=$(echo "$slug" | cut -d'-' -f1,2,3)

  # Skip drafts
  if [[ "$slug" == *draft* ]]; then

  # Generate the post's feed
  pandoc -f gfm -t html \
    --standalone \
    --variable url="$slug" \
    --variable date="$(date -R --date=$postdate)" \
    --template ../misc/post-rss-template.xml \
    "$f" >> $rss_temp

cat <<EOF >> $rss_temp

# Swap the temp file into the real file
mv $rss_temp $rss_file
chmod 644 $rss_file

In addition to that, I also added this little bit to the template page so that RSS feed readers can find the feed xml file.

  title="kitsune's blog"

If you wanna have a look around, the build script is available at /