metadata fields

131 views
Skip to first unread message

Conal

unread,
Jul 7, 2011, 8:57:19 PM7/7/11
to hakyll
I'm getting started with hakyll -- hopefully to replace my wordpress
blog (http://conal.net/blog). A question: how can I find out the
various available metadata fields (beyond author & title)?

- Conal

Jasper Van der Jeugt

unread,
Jul 8, 2011, 2:57:54 AM7/8/11
to hak...@googlegroups.com
The metadata fields used are basically arbitrary. You can put any
(alphanumeric) key in the metadata header, e.g.

---
mood: happy
weather: Sunny and warm!
---

A few keys are added when you use `pageCompiler` [1]. These are:

- `url`: the destination of the page, e.g. "/posts/2011-07-08-a-post.html";
- `path`: the source, e.g. "/posts/2011-07-08-a-post.markdown";
- ...

Some other modules use other fields. This is explained in their
documentation. E.g., `renderDateField` [2] can be used to create a
`date` field based on the `path`.

[1]: http://jaspervdj.be/hakyll/reference/Hakyll-Web-Page.html#v:pageCompiler
[2]: http://jaspervdj.be/hakyll/reference/Hakyll-Web-Page-Metadata.html#v:renderDateField

Hope this helps,
Cheers,
Jasper

Conal Elliott

unread,
Jul 8, 2011, 3:07:14 AM7/8/11
to hak...@googlegroups.com
Got it. Thanks, Jasper! - Conal

Gwern Branwen

unread,
Jul 15, 2011, 7:38:19 PM7/15/11
to hak...@googlegroups.com
On Fri, Jul 8, 2011 at 2:57 AM, Jasper Van der Jeugt <m...@jaspervdj.be> wrote:
> The metadata fields used are basically arbitrary. You can put any
> (alphanumeric) key in the metadata header, e.g.
>
>    ---
>    mood: happy
>    weather: Sunny and warm!
>    ---

Investigating, this is Hakyll-specific, is it not? It seems to be
handled ad hoc in the Hakyll Page/ directory, is not covered in the
Pandoc manual and I don't see anything grepping. Also, Pandoc seems to
ignore the sections, rendering them as text.

I really would like my files to work with both Gitit and Hakyll, but I
also want to populate properly the <meta> description tag using
description:. Any chance you could ask John to generalize the
supported metadata in Pandoc to the Hakyll scheme?

--
gwern
http://www.gwern.net

Jasper Van der Jeugt

unread,
Jul 16, 2011, 3:06:48 AM7/16/11
to hak...@googlegroups.com
I've thought of the possibility of letting the user create a
`.metadata` file with exactly the same file name. That way, there
would be a general way to add metadata, which would also work for
images etc. I would prefer this solution since it doesn't touch the
files at all.

Cheers,
Jasper

Gwern Branwen

unread,
Jul 16, 2011, 9:36:49 PM7/16/11
to hak...@googlegroups.com
On Sat, Jul 16, 2011 at 3:06 AM, Jasper Van der Jeugt <m...@jaspervdj.be> wrote:
> I've thought of the possibility of letting the user create a
> `.metadata` file with exactly the same file name. That way, there
> would be a general way to add metadata, which would also work for
> images etc. I would prefer this solution since it doesn't touch the
> files at all.

I wouldn't like that at all! Doubling my file count and splitting up
the logical file among multiple files and now a new extension to deal
with for MIME or Gitit purposes? No thank you... Especially since
extended metadata has been discussed for gitit/pandoc several times
before, almost always in-file.

Looking even harder, it seems that Gitit already has a metadata format
similar but not compatible with the Hakyll hack:

http://gitit.johnmacfarlane.net/README#page-metadata

Valid YAML, too. IMO, Hakyll should switch to the Gitit format as soon
as possible. The change is easy (change the second --- to ...) and the
sooner the better because of installed bases.

(I'm currently adding description: field to Gitit and then a <meta>
tag in its generated HTML.)

--
gwern
http://www.gwern.net

Conal Elliott

unread,
Jul 17, 2011, 11:57:05 PM7/17/11
to hak...@googlegroups.com
+1 on tweaking either gitit or hakyll to agree on metadata format. - Conal

Jasper Van der Jeugt

unread,
Jul 18, 2011, 10:20:00 AM7/18/11
to hak...@googlegroups.com
I will tweak hakyll for this purpose, it was time migrate hakyll to a
proper parsec-based parser anyway.

Cheers,
Jasper

Jasper Van der Jeugt

unread,
Jul 18, 2011, 12:51:38 PM7/18/11
to hak...@googlegroups.com
This should now work [1] in Hakyll 3.2.0.4, which I've just uploaded
to Hackage. Let me know if any problems arise.

[1] https://github.com/jaspervdj/hakyll/commit/308323bfc1e7da4b88cd83c6db265e709bec3f2c

Cheers,
Jasper

Gwern Branwen

unread,
Jul 18, 2011, 2:18:54 PM7/18/11
to hak...@googlegroups.com
On Mon, Jul 18, 2011 at 12:51 PM, Jasper Van der Jeugt <m...@jaspervdj.be> wrote:
> This should now work [1] in Hakyll 3.2.0.4, which I've just uploaded
> to Hackage. Let me know if any problems arise.

I've installed, edited all my fields, and synced. It seems to be working.

Which makes me think about another question; my description fields are
decent abstracts, which I've long felt my articles need. Does anyone
have good ideas on how to visually present them on pages? Just putting
them in my usual > quotes would clash with articles which already have
quotes as prefaces or epigraphs.

--
gwern
http://www.gwern.net

Reply all
Reply to author
Forward
0 new messages