1

I'm just starting out with Hakyll and am working with the default site that comes with hakyll init. I tried putting the following in 2015-08-12.spqr.markdown:

$partial("includes/DB.hs")$

It didn't work as expected - the post just showed the literal text $partial("includes/DB.hs")$. It didn't pull in the content of includes/DB.hs into the post. Then I tried adding the following to site.hs, but even this didn't work:

match "includes/*" $ compile templateBodyCompiler

What am I missing?

Saurabh Nanda
  • 6,373
  • 5
  • 31
  • 60

1 Answers1

4

Partials are only recognised inside templates. You would need to compile the posts with templateCompiler or by using applyAsTemplate. You can see it in the example’s index.html compilation.

applyAsTemplate is especially useful when you also want to transform the text some more, for example to process markdown:

compile $ do
    getResourceString
        >>= applyAsTemplate someContext -- e.g. defaultContext
        >>= renderPandoc
        >>= loadAndApplyTemplate "templates/default.html" indexCtx
        >>= relativizeUrls
Jan Tojnar
  • 5,306
  • 3
  • 29
  • 49