My Jekyll Workflow

Posted on: 26th March 2021

Cumbersome. That’s how I would describe my previous workflow to write a post. It involved going to my blog post folder, copying the latest markdown file to make a new file, and editing the new file with new content. Just to avoid dealing with the liquid template on top of the post. Ugh. Last week I found this bash script by @joeligj12. A quick edit to format multiple tags, removing extra liquid content that’s not used in my blog, setting the layout to ‘post’ as default, binding $mod+J to the script in Sway config and the script was ready for business. I tend to keep the markdown file name and the post title same so fixed the script to have one less dialog. This is how my modified script looks like:

#! /bin/bash 
path=/path/to/jekyll/posts

name=$(rofi -l 0 -width 40 -p "Filename (ESC to quit):" -dmenu)

if [ -z $name ]; then
	exit
fi

# replace all blanks with -
file=${name// /-}

today=$(date +"%Y-%m-%d")
filename=($today-$file)
title=$name
tags=$(rofi -l 0 -width 45 -p "Tags:" -dmenu)
tags="[${tags}]"
num=0

while [ $num = 0 ]; do

	choice=$(echo -e "Edit file\nEdit title\nEdit tags\nCancel" | rofi -width 15 -l 5-p "Now?:" -dmenu)

	if [[ $choice = "Edit file" ]]; then
  	touch $path/$filename.md
  	echo -e "---\ntitle: $title \ntags: $tags \nlayout: post \ndate: \"$today $(date +"%T") -0600\" \n--- ">> $path/$filename.md
		num=1
		kitty -e nvim $path/$filename.md & disown
	elif [[ $choice = "Edit title" ]]; then
		title=$(rofi -l 0 -width 50 -p "Title:" -dmenu)
	elif [[ $choice = "Edit tags" ]]; then 
		tags=$(rofi -l 0 -width 45 -p "Tags:" -dmenu)
	else
		num=1
	fi
done

This removes a considerable friction in writing a new post.

For fans of GUI and CMS style content management, I found this plugin called jekyll-admin. Test driving it wasn’t a pleasant experience and the UI was a little buggy. I am not sure if it was my browser or the plugin but I ended up ditching it. Your mileage may vary.

Day 97 - Join Me in #100DaysToOffload

tags: 100daystooffload jekyll