Hakyll not being able to load a post even though it outputs it

I’ve been facing issues using Hakyll. I’m trying to move to using Hakyll from Slick, and one thing I’m finding is that the errors are definitely very confusing and not as helpful as they could be. here’s what i ran:

% cabal run exe:site -- rebuild
Removing _site...
Removing _cache...
Removing _cache/tmp...
Initialising...
  Creating store...
  Creating provider...
  Running rules...
Checking for out-of-date items
Compiling
  updated web/css/style.css
  updated web/images/github-logo.svg
  updated web/images/mastodon-logo.svg
  updated web/templates/atom.xml
  updated web/templates/footer.html
  updated web/templates/header.html
  updated web/templates/post-list.html
  updated web/templates/post.html
  updated web/templates/default.html
  updated style.css
  updated web/posts/2023-07-20-hello-world.md
  [ERROR] Hakyll.Core.Compiler.Require.load: web/posts/2023-07-20-hello-world.md (snapshot content) was not found in the cache, the cache might be corrupted or the item you are referring to might not exist

here’s my app/Main.hs: paste.rs - Rocket Powered Pastebin - Code
and here’s my tree: paste.rs - Rocket Powered Pastebin - Code
here’s the web/posts/2023-07-20-hello-world.md file: paste.rs - Rocket Powered Pastebin - Code

Strangely enough, Hakyll seems to have outputted this file (but .html) to _site anyways. Weird.

The error arises from the rss.xml rule, which tries to load "content" snapshots of the posts even though said snapshots haven’t been saved elsewhere. Adding a saveSnapshot "content" to the web/posts/* rule, presumably in between pandocCompiler and the template applications, should fix it:

  match "web/posts/*" do
    route $ setExtension ".html"
    compile $ pandocCompiler
            >>= saveSnapshot "content"
            >>= loadAndApplyTemplate "web/templates/post.html" postCtx
            >>= loadContentDefault postCtx
2 Likes