Have fun with pelican site generator

Have fun with pelican site generator

Mon 26 January 2015

In this post I expand my findings about the static site generator pelican.

If you followed my previous post about pelican you already have Pelican installed and probably seen the default theme.

In this post I will show you how to download a lot of plugin and themes that you can use in your own project.

Install plugins

git clone https://github.com/getpelican/pelican-plugins

Fix your config to point at your plugins folder

PLUGIN_PATHS = ["/Users/username/Utvikling/spyder/ssg/pelican-plugins",]
PLUGINS = ["liquid_tags", "sitemap", "read_more_link"]

It will now load the plugins listed in the plugins array. To get the list with a short description of all the plugins you downloaded visit: https://github.com/getpelican/pelican-plugins

Install themes

git clone --recursive https://github.com/getpelican/pelican-themes

Set the desired theme in your pelicanconf.py file

THEME = '/Users/username/spyder/ssg/pelican-themes/gum'

You can browse all the themes (with screenshots) at: http://pelicanthemes.com

Static content

STATIC_PATHS = ['images','files']

The content of STATIC_PATHS are copied to your output folder without modification. The default value of this variable is 'images' which gives a good starting point. Remember that your STATIC_PATH folder must reside inside your content folder.

As I have a migration from joomla -> pelican my images folder contains a lot of empty (0-bytes) index.html files that I need to remove.

$ cd pelicanroot/content/images
$ find . -name "index.html" -exec rm -rf {} \;

Now all my empty index.html files are gone, but there is still some HTML content in my images folder that I dont want Pelican to bother with. So instead of deleting more files I use on of the features available in Pelican.

ARTICLE_EXCLUDES = ['images']

This will tell Pelican to not process any html/md content found in the images folder.

Create your own theme

The next step for me was to create my own theme which, was easy as soon as I understood the basics. Pelican use the Jinja template engine which is one of the most used template engines for python.

To create a theme in pelican you have to use a specific structure of files and folders. A good tip is to see how the other templates are built before starting on your own.

Tagged as : python pelican