Re: [hakyll] Changing filenames gives [ERROR] Missing field $posts$ in context for item archive.html

343 views
Skip to first unread message

Clement Delafargue

unread,
Jun 5, 2013, 4:21:29 AM6/5/13
to hak...@googlegroups.com
You still have a call to recentFirst l55.

You should write a recentFirst' based on chronologicalItems (something like fmap reverse . chronologicalItems)

Clément.

Cordialement,
Clément Delafargue
cle...@delafargue.name
http://www.eklaweb.com

PGP Fingerprint : 5311 A6C4 8416 5378 3019  B977 FFB4 9299 EAE0 ED53


On Tue, Jun 4, 2013 at 11:58 PM, <nabil....@gmail.com> wrote:
Hello all,

Noob question.

I'm trying to set up a site using Hakyll and I'm having a strange problem with my attempts to move away from the convention of dates in filenames. I was able to make Hakyll get the date field from the metadata rather than the filename with no problem, but I get the error in the subject line:

[ERROR] Missing field $posts$ in context for item archive.html

when I rename a file in the posts directory from 2013-06-04-carpe-diem.markdown to carpe-diem.markdown. I can't find anything in the documentation, or think of any reason, why changing the filename should affect the posts field.

Can anyone shed some light on this? I've attached the entire site.hs file for reference; it is little changed from the default generated by hakyll-init. If it is more convenient, you can also view it at http://hpaste.org/89317.

Thanks,
Nabil Hassein

--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

nabil.hassein

unread,
Jun 5, 2013, 8:15:42 PM6/5/13
to hakyll
I took Clement's suggestion, but I still get the same error. Perhaps I
should add that ghc --make site.hs compiles just fine; I get the error
I copy-pasted above then I try to run ./site build.

On Jun 5, 4:21 am, Clement Delafargue <clem...@delafargue.name> wrote:
> You still have a call to recentFirst l55.
>
> You should write a recentFirst' based on chronologicalItems (something like
> fmap reverse . chronologicalItems)
>
> Clément.
>
> Cordialement,
> Clément Delafargue
> clem...@delafargue.namehttp://www.eklaweb.com

nabil.hassein

unread,
Jun 5, 2013, 8:26:05 PM6/5/13
to hakyll
Ack, a typo in my previous message totally changes the meaning. I
meant:

I should add that ghc --make site.hs compiles just fine; I get the
error I copy-pasted above WHEN (corrected) I try to run ./site build.

I was trying to say that I compile first with no error, and then after
that, the error i posted is among the results of "./site build".

m...@rafal.io

unread,
Jul 14, 2013, 9:26:15 AM7/14/13
to hak...@googlegroups.com
Hi,

Unfortunately I don't have a solution, but I'm having exactly the same issue, so hoping someone could help us?

Thanks,
Rafal

jvta...@gmail.com

unread,
Aug 2, 2013, 6:12:23 PM8/2/13
to hak...@googlegroups.com
Your `dateCtx` seems weird. I don't know exactly how it behaves, but since the date is not part of the filename anymore, the `getItemUTC` l.90 tries to parse the `date` and `published` fields.

I can only guess that the default date field value "unknown date of posting" of the `dateCtx` l.76 disrupts the `getItemUTC`, which then disrupts the `forM` in the `withTime` function l.89.
Your post list would then be empty, and the `$posts$` field would not be set, thus triggering the error.

There is a lot of speculation here, but it's late and I am on my gaming PC, so no haskell :/

Hope this helps,
Julien

Jasper Van der Jeugt

unread,
Aug 12, 2013, 7:41:29 PM8/12/13
to hakyll
An additional note: running with `-v` gives a lot of extra info and
might help us figure out this issue.

Peace,
Jasper

dtfl...@gmail.com

unread,
Aug 12, 2013, 9:21:06 PM8/12/13
to hak...@googlegroups.com
Hey Jasper,

Just getting started with Hakyll. Looking good so far but I had a similar problem to OP.

OP, after trying for a few hours, I can't seem to find why your code is not working. 

@Jasper, one problem I did find though is that dateField at least currently doesn't actually support using the published or date metadata fields to get the date. Reproduction steps are as follows:

1. Make example site.
2. Delete the date prefix in one of the markdown post's filename.
3. Add the follow lines below the title metadata
---
published: 2012-07-07
---
4. Try to rebuild the site. Will error with "missing field $date$ for item posts/(whatever file you modified)"

I've added the bug to the issue tracker on GitHub.

Also, I would like a mention of this point in the tutorial. I'm all for defaults over configuration but they should be mentioned. I would like this mentioned in the tutorial especially because making new posts and new fields based on posts are key elements in copying/extending tutorial example. 

I found the problem extremely frustrating because the problem has nothing to do with code or templates. Just the file name. Also the examples/documentation often say something like "posts/foo.markdown" which obviously will not just drop into the example site.

Thank you for Hakyll though! I'm really enjoying learning more about the system but I felt that this was a surprise gotcha that really frustrated me.

Ward regards,

David Flicker

Jasper Van der Jeugt

unread,
Aug 13, 2013, 4:17:24 AM8/13/13
to hakyll
Hey David,

I can't reproduce this issue with the latest Hakyll -- it works fine
for me. I moved a post to `posts/spqr.markdown` and changed the
contents of that file to:

---
title: S.P.Q.R.
published: 2012-07-07
---

Mauris in lorem nisl...

Am I missing something? What version of Hakyll are you using?

Peace,
Jasper

David Flicker

unread,
Aug 13, 2013, 6:21:28 PM8/13/13
to hak...@googlegroups.com
Hey Jasper,

I was being extremely stupid and not realizing that to add more metadata this format should be used:
---
title: Foo
published:2012-05-05
more_metadata: Bar
---

I was doing this:
---
title: Foo
---

---
published: 2012-05-05
---

Thanks for the help!

Warm regards,

David
 


You received this message because you are subscribed to a topic in the Google Groups "hakyll" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hakyll/9EZ73CjsPko/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hakyll+un...@googlegroups.com.

tyr.god....@gmail.com

unread,
Nov 8, 2015, 6:00:53 PM11/8/15
to hakyll, cle...@delafargue.name
I feel like a fool, the parse function is very picky.   I was trying to debug why it wasn't
parsing 2015-11-8 and just failing, and I had removed the filenames, and was trying all kinds of things from this thread, but it turns out that you are required to have 2015-11-08.
See the difference?

I feel like the error message could maybe be more clear as to the error.
Reply all
Reply to author
Forward
0 new messages