All posts

Building A Simple Minimal Blogging Platform

This post details a ultra minimalist blogging platform build with just a static web server and little bit of node. This has been in my bucket list for a long time. I have been quite disillusioned with the blogging platforms recently and hate the bloated, inflexible stuff I get with every possible system. Blogging should not be this hard. It is just a bunch of text and media organised in a chronological order. A simple blog should not need a complicated database, preprocessor and hundred different plugins. So I created my own blogging platform. The GitHub repository is here - Simple-Blog.


Since I am building this, I am going to build it to my needs. The following are the requirements I need from a simple blog,

That is it. I need nothing more than this for my blog. No login or web analytics as I don't want to collect any user information, No search since Ctrl+F in a page and Google search works fine.

Blog page

This is the simplest part of it all. HTML and CSS has come a long way there is no need for myriad of libraries to get media working anymore. Writing text is simple - just write it directly as html in the html files. I seriously wonder why people don't like writing plain html. It has little quirks but for all purposes it just works. Plain HTML5 can give me text, image, video and code functionalities out of box without the need for any libraries. The only place I include any library (D3 in this case) is when I need to do something interactive within the page. Otherwise I don't include any libraries. Just plain old HTML. I can just log into the server via ssh and edit the source files with vim.


This is a bit more complicated than just writing plain HTML. I chose to make a bash script which finds all the .html files in the posts folder and creates a json file with all the required details. I have put the details in the <meta> tags and use grep and some regex to extract them. jq finally converts them into proper JSON object. This json is then fetched by JavaScript to populate the main blog roll. Ajax calls don't need any library as asynchronous fetch() function is built in JavaScript now. The script is here. This script can be symlinked to /usr/bin/ so that it can be run regularly to keep the front page updated. I can even have draft pages with different extension such as .htm which makes sure that they don't show up in the front page but can be previewed at the corresponding path.

edit: I have changed it to a static page generator to improve readability in javascript less browsers (w3m,links etc.)

RSS Feed

By definition, RSS is simple. For a simple personal blog, one can just write RSS feed from scratch. Just need to add item tag at the top of the list whenever a new post needs to be published. I chose to keep it manual as this one might be sent as updates and I want to have complete control over it. I followed these instructions for a simple feed and it pretty much works flawlessly.

About Page

This is the same as the blog pages but I added some more css rules in the HTML to make it look different. This way, the look and feel of this page is the same as the rest of the pages but the page specific stuff stays here.

Responsive Design

I have meddled with bootstrap a lot! It used to be my go to library for creating responsive pages but as I learned about flex boxes and @media rules, I realised that for the simple things I do, I don't need bootstrap. It brings me more pain and complexity than functionality. For this blog I just used simple CSS to create the layout. HTML is responsive out of the box. All I have to make sure is that the viewport meta tag is set properly and use em to set sizes etc.


Since we don't need any server side preprocessor all we need is a simple static file server. Nginx is perfect for that. Setting up Nginx is a breeze and certbot can take care of the ssl certificates for https.


This is the trickiest part of the whole set up. Since Nginx is set up just as a file server, sending back data is not possible just with nginx. So I created a simple nodejs http server which listens to connection from within the server and then use nginx to forward it to outside the server. This nodejs server gets the data sent to it as a POST request and saves it to disk by appending to a file. This avoids the need for a database and nginx can serve this as a normal file which avoids the need for node to get the data back. I used pm2 to deploy the node server, which is kind of overkill, but a normal background process should be enough for low traffic blog.


This is again done through bash script. nginx creates detailed server logs as plain text and gzip archives and all I have to do it filter and count them using grep, awk, sort and uniq. I chose two metrics - number of unique IPs and number of requests on .html pages on the server. This may not be accurate, but is enough to see how my blog is doing in terms of traffic without need for any third party tools. The sample output is given below,

30/Dec/2018 38 123
31/Dec/2018 49 349
01/Jan/2019 41 231
02/Jan/2019 205 541
03/Jan/2019 342 815
04/Jan/2019 89 209
05/Jan/2019 40 144

I think this is enough information to know about the performance of the blog for now. If I need more, I can always use the server logs. Any more engagement with audience can be done over the comments section