Make a Pelican Blog

How to setup Pelican to build a blog with Travis-CI

The goal of this post is to use Pelican, a static-blogging Python package, and Travis-CI to automatically deploy a Github-hosted blog. Your blog's URL will be username.github.io. You will need Github and Travis-CI accounts.

I chose to use Pelican instead of other Python alternatives after reading this Jake Vanderplas post. These instructions are written for Linux-based operating systems (my computer uses Linux Mint) and some workarounds may be necessary if you have another operating system to install software.

Outline

Create Github blog source repository

Install Pelican

Connect Github and Travis-CI

Create Github blog repository

Make first blog post

Deploy Travis-CI

Create Github blog source repository

We will use two separate git repositories on Github for the source and the built website, let's first only create the repository for the source

Login to Github and create a repository named: <username>.github.io-src. Initialize this repo with a README.md so you can clone immediately. The <username>.github.io-src repository is the source repo for the Pelican blog.

Virtual Environment Blogging

I recommend creating a virtual environment to blog in for flexibility with Python package installations.

conda create -n blog python==3.5
source activate blog

Install Pelican

pip install pelican

Additional packages to install for website development

pip install markdown fabric beautifulsoup4 typogrify pillow webassets

Change directory to <username>.github.io-src folder

Run pelican-quickstart to set up the Pelican blogging platform. The screenshot below shows how to answer the quickstart questions to allow your blog to be hosted on Github.

Running sh deploy.sh creates the built_website folder that contains all website data, from .html pages to css stylesheets
I receive an access denied/authentication error the first time deploy.sh executes

Add your <username>.github.io repository as the origin in built_website folder