Pelican Brief

Posted on Wed 16 August 2017 in Technology

No, this is not about John Grisham's third novel or a 1993 movie starring Julia Roberts and Denzel Washington. Instead, I'm referring to a static web site generator application named "Pelican".

Overview

So, what is a static site generator? The concept is kind of a throw-back to the earlier days of the internet when web sites were largely just a collection of HTML files. A static site generator can take text files stored locally on your computer, convert them to HTML and generate a multi-page web site from them. The resulting HTML output can then be uploaded to your web server. Pelican is one of the many available site generators out there.

The reasons I chose to move my site from WordPress to Pelican include:

  • No back end database. This means I no longer have to keep the MySQL database running for WordPress to store it's data.
  • I really only have a few blog posts and so the SSG is a perfect solution for creating Markdown files for the articles. I love markdown, it's great.
  • I hope it will be easier to write articles, since I can do it when I am offline.
  • I also looked at Hugo and Jekyll which seem like great tools. One reason I chose Pelican over those is that it is written in python, meaning it will be easier for me to tweak it if I really get deep into using the tool.
  • Since the articles are written locally, I always have a back up.

Lessons Learned

Getting started with a new tool always has it's learning curve. I am not writing this to tell you how to get started, there are plenty of articles for that... I just want to share some of the tricks that I learned in setting up and deploying Pelican.

Take advantage of the metadata syntax for posts.

Here is some of the metadata fields that can be used (this is from the Pelican docs). It also looks like you can create you own custom metadata fields for various purposes such as displaying certain values in your template.

Date: 2010-12-03 10:20
Modified: 2010-12-05 19:30
Category: Python
Tags: pelican, publishing
Slug: my-super-post
Authors: Alexis Metaireau, Conan Doyle
Summary: Short version for index and feeds
Title: My super title

Defaults for the metadata can be set in the 'pelicanconf.py' file.

This means that all the tags shown above are not needed. For example, if you are the only author, you can let the default value be picked up in the configuration file. As I started incorporating a theme, I found that many additional values needed to be added to pelicanconf.py in order to configure the theme properly.

Take advantage of creating a folder structure.

You could have all your articles in the "content" folder. But, this would become very unwieldy if you have hundreds of posts. Instead, create folders for each category on your site. In my case, my folder structure is as follows:

content/
  +-- Faith
  +-- Family
  +-- Reading
  +-- Technology

Place your posts in those folders. Then when you run the pelican content command to build your site, it will automatically generate the categories for your site based on those folder names.

Find out more

To decide if a static site is good for your situation, check out this article from Sitepoint.

A good place to find what static site generators are out there is at StaticGen or this Netlify article.

See the Pelican Documentation to find out how to get started with the tool.

I'm currently using the Flex theme. Like the way it looks and all the configurable options. Nice work!