Building a Personal Site using Pelican

Posted on 12 Oct 2017 in Full-Stack Web Development • 2 min read • updated on 2017-11-15 19:00:00+01:00


I would like to share my experience building this site using the Pelican site generator. In the last two years, I was trying several CMS, web frameworks and static-site generators for different purposes. At the end, I found out that Pelican is the most suitable for my requirements. But wait, what was my motivation for that whole works and for the reader? The motivation of this article is to explain how to build a professional personal site which is free.

The definition of a professional site can be vary for each person. Thus, here are my requirements for my professional website:

  • a light and simple web framework
  • easy to use and to deploy
  • Markdown support
  • modular and can be customized easily
  • if possible Python based

Comparison

These are the CMS that I've tried:

  • WordPress
  • getSimpleCMS
  • Django CMS
  • Mezzanine
  • Grav
  • Wagtail
  • Quokka CMS

Compared to the static site generator, the CMS's above are not light enough and many components are redundant.

I tried Jekyll, however, for me, it has too few features. Before I decided to choose Pelican, Nikola was my favorite until I had difficulties to customize a theme. In my opinion, Nikola has too many file dependency in order to customize a theme.

After some research and testing, I found out that the flex theme is very suitable for my design. Furthermore, the theme provides a very professional configuration setting.

Publishing with Github and Cloudflare

In order to publish my site freely, I can use the Github Pages service. I created a new repository <username>.github.io, and pushed only the output folder from the pelican to the repository. I followed the tips from the documentation [1]. However, I use the publishconf.py instead of pelicanconf.py. I summarized these command lines to a shell script:

pelican content -o output -s publishconf.py
ghp-import output
git push -f https://github.com/<username>/<username>.github.io.git gh-pages:master

Don't forget to install the ghp-import with pip install ghp-import, and read the extra tips #2.

Unfortunately, I had difficulties to publish my site after pushing the CNAME. The first reason was that the stylesheet and the other resource files are called with the custom domain as the base URL so that the resource files cannot be found. Seconds, there is an incompatibility between HTTP and HTTPS communication during the data request to the server. I need a separate certificate for my domain if I want to use HTTPS since the GitHub certificate only supports the *.github.io domain.

To solve this issue, I use the Cloudflare service to set up my HTTPS site. Thanks to these guides ([2], [3], [4]) that I can setup SSL for my personal site.


References

  1. http://docs.getpelican.com/en/3.6.3/tips.html#publishing-to-github
  2. https://www.jonathan-petitcolas.com/2017/01/13/using-https-with-custom-domain-name-on-github-pages.html
  3. https://hackernoon.com/set-up-ssl-on-github-pages-with-custom-domains-for-free-a576bdf51bc
  4. https://www.namecheap.com/support/knowledgebase/article.aspx/9607/2210/how-to-set-up-dns-records-for-your-domain-in-cloudflare-account