haskellrouteshakyll

Hakyll not updating with new routes


I'm trying to use Hakyll for the first time. Following the tutorials on the official site, I'm trying to extend the route handling images to work with fonts. I've changed the code in site.hs to this:

match ("images/*" .||. "fonts/*") $ do
     route idRoute
     compile copyFileCompiler

In the fonts directory, I've got a number of .ttf font files whose permissions and owners match the rest of the site's static files (all of which work properly).

For some reason though, after rebuilding the site (with stack exec site rebuild), these updates aren't reflected in the binary, and routes to fonts/* result in a 404.

How can I get Hakyll to load fonts?


Solution

  • stack exec site rebuild rebuilds only the site data (the files generated inside the destination directory, _site by default). Whenever you change your site source, you will need to issue stack build.

    If you were running the watch server, restart it – stack build creates a new site executable, it will not restart old running instances.

    If you only added new rules, executing site rebuild after the site was built should not be needed, site build or site watch should notice that the files are missing in the ‘cache’. If you modified existing rules, however, you will need to let Hakyll know the files are no longer up to date. Cleaning the site using site clean or site rebuild will force the Hakyll to re-generate everything. When you have large site and only few files affected by the change, you can also re-save them or change their modification time (e.g. using touch command) to save time.