Introduction

Just like Jekyll and Hugo, Pelican is another Static Site Generator. As Jekyll is build on Ruby and Hugo on GO, Pelican is build on Python. Therefore, if you know Python, this should be the most appropriate for you. In a previous article I showed you how to install Pelican on Python 2.7.5. In this one, I will show you how to install Pelican on Python3.

Contents:

Prerequisites
Installing Python3 from EPEL repository
Install Pelican
Start a Pelican project



Prerequisites


In order to install Pelican in CentOS, you will need to have Python 3.x.x installed on your system. CentOS 7 comes with Python 2.7.5 installed by default, thus I will install Python3 from the EPEL repository and I will use this one for my Pelican environment.

 

Top



Installing Python3 from EPEL repository


A quick method to install Python3 in CentOS is to use the EPEL repository. This will not install the latest version of Python3, but it will do. The versions available in EPEL are 3.4.5 and 3.6.3. I would advice you to install Python 3.4.5, as there are far more packages and tools available then there are for 3.6.3. For example, pip is available only for 3.4.5 and not for 3.6.

To install Python3 from EPEL, first run the command:

sudo yum search python3

This will output a (long) list of packages. To be more specific, you could try with python34 and python36. To install python 3.4.5 use the command:

sudo yum install python34.x86_64 python34-devel.x86_64 python34-tools.x86_64 python34-pip.noarch python34-markdown.noarch

Install the virtual environment tool:

sudo pip3 install virtualenv

 

Top



Install Pelican


Now you can install pelican using the command:

sudo pip3 install pelican

Next, if you like to write your content in Markdown, you will need to install the extra package for Python using the command:

sudo pip3 install Markdown

As an option, you can upgrade pip to the latest version:

sudo pip3 install --upgrade pip

 

Top



Start a Pelican project


Setup a local virtual environment for Pelican:

virtualenv ~/env/pelican
cd ~/env/pelican
source bin/activate

To start a first Pelican project, you will need to run pelican-quickstart while you are in the local environment you set up earlier.

pelican-quickstart

Now you will have to respond to all the questions the setup process will ask you. I will leave the default answers to all, except the ones that ask you about the website name, the owner name and the url.

Now you can create content using Markdown (this is what I prefer) and save the files in the /content directory inside your environment directory created at the beginning. Save the files using the .md or .markdown extension and then run the following command while still inside the content directory:

pelican content

Now move to the /output directory and run the pelican server using the command:

(and for Python 3)

python -m http.server

To test your content and site, open a browser and go to the address http://localhost:8000.

This is it. Enjoy creating your static website. To deploy your website, you will need to copy your /output directory to the webserver through SSH.

That’s it! Enjoy!

 

Top