haunt: how to hotreload the theme
thierry ·
Haunt can automatically rebuild the site whenever it detects a change. However, I had the issue where changes to my theme, which is its own theme module in "theme.scm", would not get picked up during the rebuild. Haunt would detect the theme changed and trigger a rebuild, but the changes would not be applied, until I completely restart haunt serve --watch. This made iterating on the layout quite unfun, having to switch back and forth between my editor, terminal and web browser.
The issue happened to come from the language itself: Guile will not reload modules that are already loaded. This is a perfectly reasonable optimisation, but it got in my way of editting my site's layout. I couldn't make it work using reload-module, so I used load instead. I had to remove the bits declaring "theme.scm" as a module and directly load the file in my Haunt config. This way, the theme would not be memoized at startup and I could hotreload changes to my layout without restarting haunt!