Blog of Andrés Aravena
Blog:

Replacing Jekyll by Makefile

17 February 2019

I’m not very happy with the speed of Jekyll, and with the lack of interaction with the parts of the blog made in Rmarkdown. I also do not like that Jekyll is written in Ruby, one of the languages I do not want to learn.

I have been looking at Hakyll, which is an alternative based on Haskell. The advantages are:

the bad news are:

So I was preparing myself to learn Haskell when I realized that the key ideas of Hakyll can be done in a makefile. The component of Hakyll are:

These three elements can be done in a makefile.

Types of rules

Date format

This is the hard part so far. Files can have different date formats, and we need to translate them. I think this will be handled by the same script that produces _data/auto.

Templates

Pandoc can use templates, but they cannot use include. Moreover, I like in Jekyll that “specialized” layouts can inherit from “parent” layouts. Maintaining coherently several templates can become a headache. Therefore I think that there must be also some rule to make templates from smaller pieces.

I think this can be done in AWK. Maybe the inheritance can be done in the order of the command line:

BEGIN { old="$body$" }
$0=="$body$" {a = a old}
SAMEFILE {a = a $0; next}
NEWFILE {old=a}
END {print a}
# plus some rule to handle include

Tidying up

The last part is to get rid of files that are no longer valid. Since we can compute TGT, and maybe some specific extras, we can have a command that removes all “extra” files before compiling.

Care must be taken with the files produced by Rmarkdown. Right now, with intermediate steps, this is not an issue.

Extensions

Pandoc also allows us to use filters to change the meaning of some markup. I think this can be done to transform footnotes into margin-notes. Maybe it can also do some computing, like python chunks.

Let’s see.

Originally published at https://anaraven.bitbucket.io/blog/2019/blog/replacing-jekyll-by-makefile.html