I felt the need to renumber my blog posts file names from a date (e.g., 20211222.md) to a sequence (e.g., 087.md). Hugo does a nice job of putting posts from the same date into a folder labeled for that date, so the date numbering was restrictive if I wanted to create two posts on one day (admittedly, a rarity). A number also is a nice way for me to keep track of how many posts I’ve written since I started doing this again.

The process was simple. The first thing I did was rename all of the files in the post directory using a simple bash script:

ls -v | cat -n | while read num file; do mv "$file" `printf %03d.md ${num}`; done

After that, I used another bash command to find where I had cross-linked between posts:

find . -name '*.md' -exec grep -H "https://l10systems.com" {} \;

I didn’t write a script to map the numbers to the dates. That would have been cool, but there weren’t that many and so I just spent 15 minutes updating the links from the old naming convention to the new one.

Lastly, I just committed all of the changes, pushed them to GitHub and let the build script work it’s magic.

After this exercise, I’ve got a new naming convention that easily supports multiple posts in one day.

Update: I also updated the theme to enable a traffic counter on GoatCounter. I’m not expecting any traffic but it seems like an interesting thing to look at from time to time. It was a little bit more complicated than just a simple git submodule update --remote --merge. The format of the search page had changed slightly so I had to figure out why the site build was failing and fix the page (just removed one line that is apparently no longer necessary).

bash  hugo