[web-devel] Using Hamlet for a static website

Neil Mitchell ndmitchell at gmail.com
Mon May 30 21:17:38 CEST 2011


My website at http://community.haskell.org/~ndm/ is based on lots of
template files, for example:
http://community.haskell.org/~ndm/darcs/website/pages/catch.html (not
a real HTML file, but a partial HTML file).

These files all start with some metadata, and then have some templated
language below, which gets combined with headers/footers to produce my
website. I did this all using custom code, but I'd like to move to
using Hamlet with YAML, so I can throw away lots of my custom code and
so I get lots of additional features I'm currently missing because I
have to hand-roll the framework myself. I couldn't find any examples
of anything else doing this, so two questions:

1) I couldn't find any easy way to say "run hamlet on each of the
files in this directory"? Will I have to do a getDirectoryContents in
IO, lift that into Q, and then statically call hamletFile on a list?
Then I'll output the HTML to file.

2) Is there an existing example of this? Writing a static site in
terms of Hamlet seems like a nice idea, and I can't be the first to
have thought of it.

Thanks, Neil

More information about the web-devel mailing list