hakyll- A static website compiler library

Safe HaskellNone



This module containing some specialized functions to deal with tags. It assumes you follow some conventions.

We support two types of tags: tags and categories.

To use default tags, use buildTags. Tags are placed in a comma-separated metadata field like this:

 author: Philip K. Dick
 title: Do androids dream of electric sheep?
 tags: future, science fiction, humanoid
 The novel is set in a post-apocalyptic near future, where the Earth and
 its populations have been damaged greatly by Nuclear...

To use categories, use the buildCategories function. Categories are determined by the direcetory a page is in, for example, the post


will receive the coding category.

Advanced users may implement custom systems using buildTagsWith if desired.

In the above example, we would want to create a page which lists all pages in the coding category, for example, with the Identifier:


This is where the first parameter of buildTags and buildCategories comes in. In the above case, we used the function:

 fromCapture "tags/*.html" :: String -> Identifier

The tagsRules function lets you generate such a page for each tag in the Rules monad.



data Tags Source

Data about tags


getTags :: MonadMetadata m => Identifier -> m [String]Source

Obtain tags from a page in the default way: parse them from the tags metadata field.

buildTagsWith :: MonadMetadata m => (Identifier -> m [String]) -> Pattern -> (String -> Identifier) -> m TagsSource

Higher-order function to read tags

tagsRules :: Tags -> (String -> Pattern -> Rules ()) -> Rules ()Source



:: Double

Smallest font size, in percent

-> Double

Biggest font size, in percent

-> Tags

Input tags

-> Compiler String

Rendered cloud

Render a tag cloud in HTML TODO: Maybe produce a Context here

renderTagList :: Tags -> Compiler StringSource

Render a simple tag list in HTML, with the tag count next to the item TODO: Maybe produce a Context here



:: String

Destination key

-> Tags


-> Context a


Render tags with links



:: String

Destination key

-> Tags


-> Context a


Render the category in a link

sortTagsBy :: ((String, [Identifier]) -> (String, [Identifier]) -> Ordering) -> Tags -> TagsSource

Sort tags using supplied function. First element of the tuple passed to the comparing function is the actual tag name.

caseInsensitiveTags :: (String, [Identifier]) -> (String, [Identifier]) -> OrderingSource

Sample sorting function that compares tags case insensitively.