Rolling my own Blogging Platform

Rolling my own Blogging Platform

November 30, 2026

See Blog-archaeology for the reason this project has to exist.

So any good software project should start with requirements. Here are mine:

So, I decided to use markdown as the storage/editing format.

Conversion of existing content

I know I can convert markdown to HTML, and since there is no dynamic content on the site, this could be part of the publishing step. Thus the whole site is just static HTML.

Can I convert the existing wordpress site to markdown in order to bootstrap the new system?

I looked into an “export” plugin for Wordpress, and that almost worked, but the files were a weird mixture of HTML and plain text. One posting was a bunch of paragraphs of text separated by blank lines with the entire thing wrapped in a single <p>...</p> tag. Of course this didn’t format properly when converted to markdown since it just became a big blob of text with no structure.

Enter wget --mirror, which allowed me to slurp the whole site as rendered HTML, ignoring any back-end storage weirdness. Plus it also sucked down all the images.

Wordpress stored all the useful stuff between <article>...</article> tags. I extracted this using xmllint --xpath //article.

Pandoc allowed me to convert the resulting html to markdown (I used markdown_strict-raw_html).

At this point I have all the content as markdown files and all the images that the files link to. All the one-time conversion is done.

Publishing pipeline

Now to build the repeatable pipeline.

First: convert all the markdown files to HTML. Again pandoc to the rescue. Pandoc will build complete HTML including adding specified CSS and header/footer content. The result is a directory full of static HTML files.

Now I need to build the index.html containing the table of contents with links to each posting.

Since I have a formatting convention for the postings, I can extract the title and date using simple head, sed, cut and tr commands. From this I build a .csv file containing all the posting metadata, then I use duckdb to query the CSV as if it were a database.

sed allows me to update the header/footer to point each article to it’s previous and next article.

Put the whole thing into a Makefile and now, to publish a new article (or modify an existing one):

  1. Edit a new/existing postNNN.md file. I can assign the number manually because I can see what’s in the directory already.
  2. make will build the HTML for the new posting and rebuild the index.html page to point to it.
  3. Preview the new file locally. Return to step 1 if edits are needeed.
  4. make publish will push the new file up to the web site using sftp.

So, this meets all the requirements:

Future features

Currently the publish step copies all the files up to the web server. This is a bit slow and could be improved by using rsync to only push changed/new content.

At the moment when I add a new article I have to rebuild its neighbor to insert the correct “next →” link. I have some ideas about how to fix this, but for the moment it’ll work. I just have to remember to force a rebuild of the previous article.



Copyright © 2026 Tom Malaher all rights reserved