#Skip to menu

The static site generator used to build https://xojoc.pw

Formica - static site generator


Formica is a simple yet flexible static site generator. Its main features are:


First install Golang, then run:

go get -u -insecure xojoc.pw/formica
go install xojoc.pw/formica

NOTE: -insecure is needed because I don’t yet have https on xojoc.pw and Let’s encrypt is not yet ready.

Create a new directory:

mkdir blog
cd blog
formica init

This will create the file _formica/config.yaml and will populate the directory _formica/styles/default.


$EDITOR _formica/config.yaml

The configuration file contains a list of directories and for each directory a title and rules to apply to its files. Each rule must specify the command to run, a regexp pattern to match against the input file and the pattern of the output file. Formica visits all the files in a directory and if a file name matches the input pattern of a rule it pipes the file trough the associated command and writes the output in the file named with the out pattern prepended by ’_output/’. When you run formica init the config file is populated with:

- dir: .
  title: "Amazing blog"
   - in: 'a/{slug}\.md'
     out: '{slug}.html'
     exec: pandoc

In this case formica visits all the files in the current directory (.) and all the file names of the form a/{slug}\.md are piped into pandoc and the output is written in ’_output/{slug}.html’ (_output/ is prepended by formica).

in is a regexp pattern with special syntax. The following snippets are replaced by the corresponding regexp expressions:

{id} -> (?P<id>[[:digit:]]+)
{title} -> (?P<title>[^/]+)
{slug} -> (?P<slug>[^/]+)       
{year} -> (?P<year>[[:digit:]]{4})
{month} -> (?P<month>[[:digit:]]{2})
{day} -> (?P<day>[[:digit:]]{2})

in the same way the output pattern is replaced by the metadata from the “item” being processed.


Formica collects metadata from both the header of a file and its file name. If exec is not empty the input file must have a metadata matter. All the lines up to “…” are treated as metadata unless NoHeader: true is included.

Get the code