Building a Pelican Website

Posted on We 05 Pipiri 2019 in Geekery

After a whole lotta dithering I have started building a personal blog/website with the Pelican Static Site Generator. Although I could spend further time investigating things such as Drupal, Silverstripe, Wagtail etc for extra bells and whistles it could be even longer before I have a change to put things in my head 'down on paper' for the world to see without using Facebook etc.

In part this is also notes for myself on how I install and update my website.

Installing Pelican

As mentioned this is mainly for my reference. Certainly reading the official documentation is probably a good place to start when doing anything.

Creating the virtualenv

Previous iterations of doing this I understood less about python and virtualenvs. I was using a separate virtualenv for each website I was planning on building and deploying with Pelican. It is sane and reasonable to use different virtual environments for different purposes to reduce the dependency issues, but for all my Pelican websites, I just need the one ..

sudo apt install python3-virtualenv
mkdir -p ~/Projects/virtualenvs
virtualenv ~/Projects/virtualenvs/pelican

And as I discovered you can't easily move the virtualenv directory to another part of your directory tree if you decide you have a better place for it. BUT because it should be fully repeatable, it can be deleted and recreated in the 'right' place.

Using the virtualenv

Once the Python virtual environment is in place, we can activate it so that we can use it. This is the most common set of commands that will be run as part of the ongoing development and update process ..

cd ~/Projects/virtualenvs/pelican
source ./bin/activate

Installing Pelican

I'm going to primarily be using markdown as I already use a couple of tools that use markdown (GitLab, GitHub, Nextcloud Notes) ..

pip install pelican[Markdown]

Updating Pelican

Get yourself into the virtualenv and ..

pip install --upgrade pelican

Initial Site Setup

A couple of options for the initial setup of the Pelican website. Start by creating a directory for the Pelican configuration and your website content ..

mkdir -p ~/Projects/Websites/figjam.nz
cd ~/Projects/Websites/figjam.nz

pelican-quickstart

Pelican has it's own quick setup script that will ask you some questions to get the very basics of the website configured. This was used for the first iteration of building this website ..

pelican-quickstart

I won't go into detail with the questions the script asks, should be self-explanatory. Maybe I'll come back to describe in some more detail in case I do decide to start from absolute scratch for another site.

Testing

Regular testing and checking as you go makes a big difference to the final quality as you catch (most) errors before it goes live. Pelican can regenerate the content on the fly as you save your changes. Get yourself into the virtualenv and run a simple python webserver ..

make devserver

Each time you save your content will be available at ..

http://localhost:8000/

Depending on your changes (mainly to the configuration), you may want to restart the devserver on a somewhat regular basis.

Publishing

more to come here

Theming Pelican

In the end I eventually found a 'it'll do' theme, and have done some minor tweaks to it. For my future reference, my howto is here Theming a Pelican Website