Recently, I migrated my personal website from Wordpress to Github Pages using Jekyll. After some trial and error, I managed to have everything up and running. However, Jekyll tagging (i.e., generating the pages that contain a collection of posts filtered by a tag) requires additional plugins which are not supported by Github Pages. Long Qian wrote a fantastic tutorial on how to implement this functionality with a Python script. Unfortunately, this still requires running the script, adding the files to the staging area, committing them, and pushing them to Github. That’s a lot of steps for every time that I want to add a new tag. Not only is it prone to errors, but let’s be honest: ain’t nobody got time for that.
Therefore, I automated the whole process. I adapted Long’s solution and embedded it in a more comprehensive script,
update_tags.py. Now, I let GitPython handle the Git part. This way, after I finished updating/creating a post with new tags (and pushing those files to Github), I can run
update_tags and do the rest: fish the tags used across all posts, create the corresponding posts, and commit and push these changes to Github in a single go. To keep things tidy, I recommend running this script when having a clean working space (nothing to commit/push).
Please note that Long’s original script reads the tags from posts that are formatted as follows:
I adapted the script to read tags from posts that are formatted differently:
You can find all the files of my website in my Github repository. If you still have questions about the implementation or, even better, suggestions for its improvement, please leave a comment here or file a new issue in Github.