Setting up Pelican and Netlify

Spending all day working as a system administrator, sometimes you just don’t want to spend your free time administrating more servers and services. This is the predicament I found myself in. My previous “blog” was just a static site powered by Hugo, and I really liked it. So what happened?

When I had previously setup Hugo it was all done manually, with no build pipeline, or consideration of continuous integration. It was a manual process to make changes, build the static site, and upload the files. I found myself dreading making changes to it or figuring out how to add pages/post actual blog articles. I also took it as an opportunity to gain more experience with Golang. However, the cost was losing the drive to maintain and add content. The learning curve required actively fought my drive to make blog posts or update it with changes. So, I chose to try out Netlify as a possible solution to automating some of the manual parts of maintaining a static site and hopefully gain back that drive to produce content.

After signing up, Netlify setup OAuth to my GitHub account and asked for a repository. Naturally, I paused and realized I needed actual code/content before I could proceed. So naturally with the goal of making things easier, I decided on Python/Pelican. I choose Python because it is my most fluent coding language and Pelican because that was the first recommendation that I found. After taking some time to read and research the documentation, it appeared to be mature and stable.

After setting up a new Git blank git repo, I made sure to add the git repo to Netlify so that my first commit would trigger a build. I did the following:

dpage@do-ops:~/Coding/pagefortress.com$ mkvirtualenv -p python3.6 pelican
(pelican) dpage@do-ops:~/Coding/pagefortress.com$ pip install pelican

If you haven’t used virtualenv or virtualenv-wrapper, I highly recommend checking it out here: https://virtualenvwrapper.readthedocs.io/en/latest/ It is a GREAT way to manage and organize your python virtual environments all in one place if you do not want to keep them within your project directory.

For example if you use pelican for multiple projects, instead of needing a virtualenv subfolder for each project, the venv is keep in your home directory and activated simply by typing workon pelican

(pelican) dpage@do-ops:~/Coding/pagefortress.com$ pelican-quickstart
Welcome to pelican-quickstart v3.7.1.

This script will help you create a new Pelican-based website.

Please answer the following questions so this script can generate the files
needed by Pelican.


> Where do you want to create your new web site? [.]
> What will be the title of this web site? PageFortress
> Who will be the author of this web site? Dylan Page
> What will be the default language of this web site? [en]
> Do you want to specify a URL prefix? e.g., http://example.com   (Y/n) Y
> What is your URL prefix? (see above example; no trailing slash) http://pagefortress.com
> Do you want to enable article pagination? (Y/n)
> How many articles per page do you want? [10] 5
> What is your time zone? [Europe/Paris] Eastern
Please enter a valid time zone:
 (check [http://en.wikipedia.org/wiki/List_of_tz_database_time_zones])
> What is your time zone? [Europe/Paris] America/Detroit
> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n)
> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n)
> Do you want to upload your website using FTP? (y/N)
> Do you want to upload your website using SSH? (y/N)
> Do you want to upload your website using Dropbox? (y/N)
> Do you want to upload your website using S3? (y/N)
> Do you want to upload your website using Rackspace Cloud Files? (y/N)
> Do you want to upload your website using GitHub Pages? (y/N)
Done. Your new project is available at /home/dpage/Coding/pagefortress.com

Now that the project core is ready, setup Netlify to build the site using the command:

(pelican) dpage@do-ops:~/Coding/pagefortress.com$ pelican content
Done: Processed 1 article, 0 drafts, 1 page and 0 hidden pages in 0.21 seconds.

If you run into issues with the build failing, using the -D option for debug output, to review the logs.

You can find the Pelican install documentation here: http://docs.getpelican.com/en/stable/install.html

Also make sure to freeze your pip versions to requirements.txt and set a python version in runtime.txt. See: https://www.netlify.com/docs/continuous-deployment/#set-node-ruby-or-python-version

Next, it was simple as picking a theme (http://docs.getpelican.com/en/stable/settings.html#themes) and start to write content! I chose reStructuredText, but Markdown is also supported.