Next: , Previous: , Up: Builders   [Contents][Index]

5.4.2 Flat pages

(use-modules (haunt builder flat-pages))

Flat pages cover the simple case of converting a tree of files written in some markup language to full web pages. Flat pages work great for the more informational parts of a website that don’t require any fancy programming to generate, like an “About me” page.

Procedure: flat-pages directory [#:template] [#:prefix]

Return a procedure that parses the files in directory and returns a list of HTML pages, one for each file. The files are parsed using the readers configured for the current site.

Each flat page starts with a metadata header. Only a single piece of metadata is used, though: the title.

Here’s what a flat page written in Markdown might look like:

title: About me

# About me

Hello, I am Alice!  I'm a fictitious person made up for the purposes
of demonstrating Haunt's flat page functionality.  I live here in this
manual with my two cats: Bob and Carol.

The content of each flat page is inserted into a complete HTML document by the template procedure. This procedure takes three arguments:

  • the site object
  • the page title string (from the metadata header)
  • an SXML tree of the page body

template should return a single value: a new SXML tree representing a complete HTML page that presumably wraps the page body.

Conveniently, the signature of template matches the blog theme layout procedure so that it can be reused for flat pages. See Blog for more information.

The structure of directory is preserved in the resulting pages and may be optionally nested within the directory prefix. If no prefix is specified, the files are placed starting at the root of the site.

Next: Blog, Previous: Static Assets, Up: Builders   [Contents][Index]