websites & programming

Flying with Pelican

Over the past two years, I have used either WordPress or a simple web application to generate the website for my consulting business. But I was always curious about static site generators, and recently switched over to a Python-based project called Pelican. The term “static site generator” is really just a fancy name for a program that takes a collection of text files, runs them through a templating engine, and generates a folder tree containing HTML files that can then be uploaded to a server.

When using a static site generator, there are no logons and passwords to worry about. There is no database for the website, and there is no content management system that needs to be kept up to date. Unless one truly needs CMS or e-commerce features for a website, I think the static site option can be very compelling (for peace of mind, if nothing else!)

One issue that I bumped into while getting started with Pelican was that I didn’t want .html extensions to appear in my website’s URLs, as that seemed like a step backward to the earlier days of the internet. One solution to this issue when using a static site is to save every page and blog post with index.html as the filename, and store each index.html file within a folder that has the desired URL. By doing this, each page of the website may be viewed without including the .html extension in the URL for the page. Pelican’s documentation contains a helpful section on clean URL’s that shows how Pelican can handle this for you by modifying a couple of the default configuration settings, e.g.,

ARTICLE_URL = 'journal/{slug}/'
ARTICLE_SAVE_AS = 'journal/{slug}/index.html'
TAG_URL = 'tag/{slug}/'
TAG_SAVE_AS = 'tag/{slug}/index.html'

So far I haven’t really seen a downside to using a static site generator. Adding or editing posts is very easy with Pelican. Content for the website can be written in either Markdown or reStructuredText. So why aren’t static site generators used more often than they are now? I suspect the reason is that one probably has to work in a technology-related field to have the necessary comfort level to configure and run a static site generator on a PC or Mac. No doubt web designers, software developers, and IT staff will fall into this category. But most others will find it easier to get started with either a site building tool like Squarespace or else by just using a WordPress site that a web designer creates for them.

Comments