Roland's homepage

My random knot in the Web

Installing Pelican 4

Pelican is the static site generator that I use for my website. This allows me to write my website posts in almost plain text (actually a light-weight markup language named reStructuredText), which are then translated into HTML. As someone who has written his webpages in HTML by hand, I can tell you that this is definitely an improvement.

Although I use LaTeX for things that require high-quality typesetting, these days almost all my other writings are in reStructuredText.

The previous pelican version 3.7 was basically the last Python 2.7 application that I use. So now that pelican supports Python 3, I’m switching. Since Pelican 4 is not in the FreeBSD ports tree yet, I’m installing it myself.

Note

As of 4.0.1, Pelican is now in the FreeBSD ports tree and I’m using the port www/py-pelican. At the moment I’m still installing typogrify and smartypants by hand.

Prerequisites

According to its setup.py, pelican 4 requires:

  • feedgenerator >= 1.9
  • jinja2 >= 2.7
  • pygments
  • docutils
  • pytz >= 0a
  • blinker
  • unidecode
  • six >= 1.4
  • python-dateutil

Some of those I already have installed. Luckily the rest is available from the FreeBSD ports tree in /usr/ports. So I’m installing www/py-feedgenerator, devel/py-Jinja2 (this also installs textproc/py-MarkupSafe), textproc/py-docutils, and devel/py-blinker each with the following command.

(Note that in shell commands, > indicates a command run as a unprivileged user, and # indicates a command run as the root user.)

# make FLAVOR=py37 install clean

For better typography, I’m using typogrify (which in turn requires smartypants).

I downloaded typogrify-2.0.7.tar.gz and smartypants.py-2.0.1.tar.gz and installed them.

> cd ~/tmp/src
# tar xf ../smartypants.py-2.0.1.tar.gz
# cd smartypants.py-2.0.1/
# umask 022
# python3 setup.py install
# cd ..; rm -rf smartypants.py-2.0.1/
# tar xf ../typogrify-2.0.7.tar.gz
# cd typogrify-2.0.7/
# python3 setup.py install
# cd ..; rm -rf typogrify-2.0.7/

Installation

Copying the pelican repo.

> cd github
> git clone https://github.com/getpelican/pelican.git
> cd pelican
# pkg delete py27-pelican-3.7.1
# umask 022
# python3 setup.py install

After the installation I found that the templates in the standard themes were not world readable, so I fixed that like this.

# cd /usr/local/lib/python3.7/site-packages/pelican-4.0.0-py3.7.egg/
# chmod 644 pelican/themes/*/templates/*

Updating content

When running pelican 4, I get a lot of warnings that I should use {static} instead of {filename} to link to static content.

I did this by running the following command.

> find src/ -type f -name '*.rst' -exec \
sed -i '' -e 's|{filename}/images|{static}/images|g' \
-e 's|{filename}/files|{static}/files|g' {} \;

That takes care of the warnings and finishes the update process. The last step was to remove all the Python 2.7 modules that are now not longer needed.


For comments, please send me an e-mail.


Related articles


←  Creating a nomogram with Python and Postscript Adding text or graphics to a PDF file (again)  →