Asbath's Arena

How to build a blog with Pillar

Here we are going to learn how to build a blog in Pillar. Building a blog consist of creating a website with articles (with possiblity of writing comments). So the most appropriate archetype for that purpose in Pillar is academic. We are goin to use a special annotation for getting blog files. The academic archetype propose a special template file for articles presentation containing a comment section.

So, let's install academic first:

$ pillar archetype academic

After that you have a project without blog. The first thing to do is to create a directory at the root of your project, which will contain your blog publications. So let's create it.

$ mkdir blogs

$ cd blogs

Now create some pillar files under blogs folder.

The principal annotation we are going to use in order to have our publications displayed is docList. This annotation takes a certain number of files from a specified directory and presents them like some abstracts and links to complete articles. The main parameters of this article are:

  • path: this parameter specify the path to the directory containing files to be published.
  • limit: this one is for the number of files to take into account.
  • sort: to specify the way files are going to be displayed. For the moment you can sort by name (in alphabetical order, ascending), by date (last modification date, the latest is the first to be displayed).
  • templates: this parameter is quite interesting, you specify the presentation you want your files to have. Then you propose a template and abstracts will be generated using that template, or those templates. Because you can specify many templates. If you specify 2 templates, and you have more than 4 files to generate, the first file will be generated using the first template, the second one with the second template, the third file will be generated with the first template and the next one with the second template and so on.

Let's check for some files, just put this line in your index.pillar file at the root of your project.


${docList:path=blogs|limit=3|sort=date|templates=#('templates/article1.mustache')}$

After this, modify the pillar.conf to add the appropriate transformer in generation procees.

...: .....,
"plugins": ["PRDocumentListTransformer"],

.....

.....

Build your project and you will get a list of abstracts referencing your articles.

To be reviewed (small version).