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.
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.
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 followedinstructions for a simple feed and it pretty much works flawlessly.
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.
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