Making it easier to blog

on January 03, 2020. in Blablabla. A 2 minute read.

2019 was a not so great year for my blogging. 7 posts in total. There are multiple reasons for that, all the regular stuff like “I didn’t find the time” and “Nothing to blog about”.

Currently I’m reading Atomic habits (great book by the way, do read it if you haven’t!), and one of the suggestions for starting a new habit is to make it easy to do it. So, here we are.

This blog is powered by a static web site generator, Hugo, I write the posts in plain ol’ markdown files, and use (g)vim as the editor. I even created a vim plugin to speed some things up with Hugo. Once a new post is written, I use fabric to build and deploy the site to my server. Pretty easy.

After giving it a bit more thought, there are still some steps in this entire process that I can speed up with a few more vim helpers, and a couple of bash functions.


I wrote four little bash functions to make my blogging even easier than before:

The blog function takes me to directory where I keep my blog, starts Hugo’s server in the background, waits a bit so that the site is up, and opens up my local blog in Firefox. Given that it’s a bash function, I can create a custom action in XFCE’s Application finder.

function blog() {
    cd "/home/robert/projects/"
    hugo server &> blog.log &
    sleep 3s
    firefox http://localhost:1313/blog/

blog-stop stops the hugo server and cleans up.

function blog-stop() {
    cd "/home/robert/projects/"
    pkill hugo
    rm blog.log

blog-new creates a new blog post and opens it up in gvim.

function blog-new() {
    hugo new blog/$
    gvim content/blog/$

blog-drafts lists all the drafts I currently have. They tend to pile up after a while.

function blog-drafts() {
    ag -l "^draft = true" content


As for vim, I have the vim-hugo-helper plugin, and one custom vim function that I call on a new post:

command! BlogWrite call BlogWrite()
function! BlogWrite()
    call HugoHelperFrontMatterReorder()

It calls the four Hugo helper functions that I used to call manually every time.

There’s still room for improvement, but this will do for now. I also want to figure out a way to blog from my phone, I have a few ideas for that as well. Need to test them out and see what works best.

Happy hackin’!

Tags: blogging, hugo, vim, helpers.

Get the next article to your inbox

If you'd like, you can get the next article I write to your email inbox.