Working with Hugo Themes (Part 1)
#hugo #git #howto #developmentI’m the kind of person who cares a lot about having a good looking theme for my blog before I even start creating content.
In my first days of a new blogging life with Hugo, I looked at some simple themes. And simple is what Hugo is all about, isn’t it? My first theme was Bear Cub. Nice and simple, but it lacked something special. I found bacardi55’s theme, a (smol fork), and liked it a lot. After modifying it a bit to my liking, I ended up using smol and forked it. I added this theme as a git submodule. I found this to be the easiest way to work with themes.
But how do you work with a forked theme in Hugo? Because the workflow seems to be complicated:
The (imo) bad way…
- Update forked theme (changing the CSS, templates, etc.)
- Push changes
- Fetch/pull theme (submodule) changes in Hugo environment
- Test it, fix it, go back to Step 1
- Push the updated submodule in the Hugo enviroment
The simplest CSS changes caused several commit/pushes in my repositories. This development loop was painful. Although it does not happen very often.
The solution is so simple that I got a bit angry and used this loop for a few hours.
Just start the hugo binary with the option --themesDir ~/path/to/themes
! In the folder themes
is a sub-folder with my themes:
1hugo server --themesDir ~/git/themes -D
It’s so easy. 🤦♂️