2

I understand there's an example site given by

hakyll-init app

But I'm looking to reduce even more to the skeleton, and just have 1 markdown page that renders in the root, "localhost:8000/", and an alias "localhost:8000/index.html."

From the instructions, I have created this:

.
├── app
│   ├── app.cabal
│   ├── _cache
│   │   └── d5c19886a1234f571c624d44ba520d2b
│   ├── css
│   │   └── default.css
│   ├── images
│   ├── index.markdown
│   ├── _site
│   │   ├── css
│   │   │   └── default.css
│   │   └── images
│   ├── site.hs
│   ├── stack.yaml
│   └── templates
│       └── default.html

And I have the following in:

site.hs

--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
import           Data.Monoid (mappend)
import           Hakyll


--------------------------------------------------------------------------------
main :: IO ()
main = hakyll $ do
    match "images/*" $ do
        route   idRoute
        compile copyFileCompiler

    match "css/*" $ do
        route   idRoute
        compile compressCssCompiler

    match "index.markdown" $ do
        route   $ "index" + setExtension "html"
        compile $ pandocCompiler
            >>= loadAndApplyTemplate "templates/default.html" defaultContext
            >>= relativizeUrls

    create "/" $ do
        route   $ "index" + setExtension "html"
        compile $ pandocCompiler
            >>= loadAndApplyTemplate "templates/default.html" defaultContext
            >>= relativizeUrls

--------------------------------------------------------------------------------
postCtx :: Context String
postCtx =
    dateField "date" "%B %e, %Y" `mappend`
    defaultContext

This seems to compile:

app $ stack exec site watch
Listening on http://127.0.0.1:8000
Initialising...
  Creating store...
  Creating provider...
  Running rules...
Checking for out-of-date items
Compiling
Success

But when I load http://127.0.0.1:8000, or http://localhost:8000/index.html, I don't see my template, I see:

File not found

How can I fix site.hs for a minimal Hakyll (only an index.html created from a markdown stub), and how can I understand the debugging better? Eg, here I would have liked to see some kind of "stuff won't be found" at compile time. Where would I look for that?

Mittenchops
  • 18,633
  • 33
  • 128
  • 246
  • Hum, where did you get that `"index" + setExtension ".html"` syntax? I have `route $ setExtension "html"` – arrowd Sep 21 '17 at 07:28
  • Indeed, that should not even compile `(+)` is defined on `Num` typeclass, which `Routes` produced by `setExtension` come nowhere near. – Jan Tojnar Sep 21 '17 at 07:33
  • Did you call `stack build` or `cabal build` after editing the source code? – Jan Tojnar Sep 21 '17 at 07:42
  • Was trying to concatenate. Changed to '++.' – Mittenchops Sep 22 '17 at 01:16
  • @Mittenchops That will not work either. `setExtension` does not return `String`, it just sets the extension (think imperatively). – Jan Tojnar Sep 22 '17 at 10:24
  • @JanTojnar, now that I stopped the watch process, when I try to rebuild or clean, I get: ``` [ERROR] Hakyll.Core.Compiler.Require.load: templates/default.html (snapshot _final) was not found in the cache, the cache might be corrupted or the item you are referring to might not exist``` The templates/default.html definitely does exist. – Mittenchops Sep 23 '17 at 05:01

0 Answers0