Setting up my blog

October, 17 2019 | ~6 Minute Read

The Why

I thought about doing a blog originally about 5 years ago, I wanted to have some type of outlet but I didn’t think I would have enough to say, so I kept putting it off mainly due to this reason. After some time I just decided to go forward with it and see how it went rather than make up excuses about how I wasn’t going to have enough content for it.

The idea behind this blog is to document all things related to my progress in the Linux world and development. I wanted to have a blog that complied with a few basic rules:

  1. It had to be technical in nature
  2. It had to be made entirely made from scratch
  3. It had to look modern enough for my liking
  4. I had to do it with basic tools, mainly vim

These basic rules, specially the second one, really weren’t all that bad except that I really had no idea how to do it. I took a look at several of the tools out there like jekyll which has free github hosting as well. But that just didn’t seem like something I would be happy with. “Hey wanna check out my blog, I was lazy about it and just threw on it on github”… not that there is anything wrong with doing it that way, it just didn’t seem to work out with the goals I had set in mind.

I later took a look at other similar tools like Next.js, Hugo and Gatsby. Again, all of these were great, but I just had a different approach to it all in mind. I wanted to really learn how to do it, how to develop it all, so I would like to do it from scratch.

There was generally one problem with that, it was absolutely daunting to think of creating something that is better than what open sourced frameworks did. I mean, there are literally thousands of commits to these projects, all done by much more experienced developers than myself. This is something that kept making me want to just tuck my nice little idea away, but my idea of doing it from scratch was just too stuck in my mind for me to give up on it, and the idea of doing it all on my own was just too intimidating to get started.

After this initial vicious cycle of doubt and negativity, I got interested in several fields that were new to me and wanted to learn more about, mainly cloud technology. Things like docker, cloud vendors and kubernetes popped up on my radar. This was the moment of inflection for me, I just had to get something done.

The How

I got started with just a basic HTML page, no CSS at all. I wanted to keep it simple and to the point, I had already done some work on some basic applications and I simply put links to those apps in a list.

I then started looking at places where to get some insight into how to get some CSS added and not have it be a blank slate and have some type of presentation. I was recommended to Jeremy Thomas' Web Design in 4 minutes. And basically used that as a starting point.

I then added a menu based off of W3 School’s Navbar samples. I know everyone complains about them not having proper code and such, but they have some very nice how to’s that in my opinion get things done. It may not be the best source to learn how to program or use as a reference for advanced topics, but this was simple enough.

Once I had that set up I had to figure out a way to get content up and quickly, this is mainly where things like a framework would be of great help. Because you can get one or two pages done in HTML without thinking too much about it, but once I had several dozen pages to write, I would probably get to a point where I would appreciate the consistency and ease of a framework.

I had to figure out a way of getting that done on my own, from scratch. Seeing as I wanted to use vim and had used the vimwiki before, I wanted to have a similar workflow for blog posts. The main feature that got me thinking like this was the :Vimwiki2HTML feature that the vimwiki program contains. I also used Markdown for my vimwiki so I wanted to keep doing everything in markdown.

When I initially changed from the vimwiki syntax to markdown I noticed that the :Vimwiki2HTML feature didn’t support that, and I decided to create a script that basically replaced this functionality by using the discount program. Seeing as this was pretty generic I thought the same could be done for the blog. I modified the initial script that I already had, and got the basic workflow done. The current state of the script is listed below:

 #! /bin/bash

 echo "Bash version ${BASH_VERSION}"

 echo "Building Website"

 sleep 1

 for file in /some/path/*.md
 do
    if [ -z "$(ls -A /some/path/html/)" ]; then
    fname=`basename "$file" | cut -d "." -f 1`
       echo "This is the first time building the website, creating $fname"
    markdown $file > /some/path/html/$fname  
    cat head.txt /some/path/html/$fname footer.txt > /some/path/html/$fname.html
    rm /some/path/html/$fname
    else
    fname=`basename "$file" | cut -d "." -f 1`
          echo "Creating $fname"
       markdown $file > /some/path/html/$fname  
    cat head.txt /some/path/html/$fname footer.txt > /some/path/html/$fname.html
    rm /some/path/html/$fname
    fi
 done

 echo "Website Built, opening Firefox"

 sleep 1

 xdg-open /some/path/html/index.html

This script basically does the following:

  1. Checks if a folder is empty and based on if it’s empty or not does the same action but prints a different message (This is not really necessary, but I keep it around for some reason)
  2. Reads the contents of the folder in which the .md files are stored and iterates through each .md file that it finds
  3. During its iterations it uses the discount tool to parse the markdown format to HTML
  4. It then adds some header and footer information by using the cat bash command and outputs the final HTML file
  5. Then it does minimum house keeping and deletes the initial HTML file
  6. At the end it opens a file so I can see the page locally, again this is not entirely necessary

Although this is a very simple script, and to be honest could be vastly improved, it is what I am currently using in order to get the blog posts of the page easily and automatically generated from my original markdown files, so it works for me.

Once this is done I do a test drive of the page locally and then publish it to nixing.mx.

Conclusion

I hope this gives some insight to some people out there that, like myself, are stuck in a vicious cycle of whether they should or could do a blog in a simple way. This works for me so far, and as I make changes to my workflow I will mention them here.

There are many features that I want to add to the website that I think are very important and don’t yet have, however starting somewhere and seeing progress keeps me motivated on learning how to develop those features instead of worrying about why I haven’t done anything.