« New Site for 2016
What is a TAR »

Moving to Pelican

As stated in a previous post, I have changed the site away from wordpress to pelican.

This post details the reasoning and the process of changing over the site.

Why change?

In the past the site was just static files, I then moved over to basic php files that would use include to bring in headers and footers. In 2011, the server this site was hosted on died and I lost all my files. I then rebuilt the site in wordpress.

This has served me well, was easy to tweak and is generally well supported with advice online.

Security

I reviewed the server logs and noticed a significant number of attempts to log in (that were not me). It is a testament to the quality of wordpress that none of these were successful however it made me review the site security in more detail.

When thinking about it, I have no need for a dynamic site. The content is rearly updated, and when it is, it is easy enough to do a mass upload or rsync via ssh. This completely removes the risk of someone finding a Wordpress/PHP exploit.

Speed

It should also have the advantage that the site will be faster to load.

Because there is no need to lookup a database and build a page on each request, it should be faster (although this may have minimum impact on the main pages as these will probably be cached by the system).

Quick test during development has revealed:

  • Old Wordpress Version: 24 requests, 419.92KB 1.16s
  • New Pelican Version: 15 Requests, 320.96KB, 0.76s

(Note speeds recorded on different servers, however main delay was google analytics in both cases).

Changeover process

Below I will summarise the change over process that I used to convert my site from wordpress to

  1. Export wordpress
    From the dashboard, go to tools > export or navigate to /wp-admin/export.php Download the whole site and save the xml file.
  2. Use pelican quickstart to setup empty site
    Using the command pelican quickstart answer all the relevant questions to set up the site to reflect your existing site.
    More details can be found at http://docs.getpelican.com/en/3.6.3/quickstart.html
  3. Use pelican import to setup separate site with articles and pages
    Navigate to the content directory within your project.
    The command pelican-import --wpfile -o . ~/Downloads/mysite.wordpress.2016-03-01.xml -m markdown --dir-page --dir-cat will import the wordpress xml file and extract all the articles and posts into a the new site.
    This command can be chaned to suit yourself and is documented in the pelican importer documentation
  4. Pick a theme
    Either edit the existing theme, or pick your favorite from pelican-themes and tweak that to your taste.
  5. Edit and Review all articles and copy over static files
    The wordpress import works well and gets most of the content but it is worth reviewing to tidy up the articles.
    The other thing that is not done is download all the media from your site (downloads and images) which you will have to manually download.
  6. Tweak settings to match existing site
    At this stage, it is just a lot of tweaking and reviewing, checking the RSS feed is similar, archive pages work etc.
    More details can be found in the pelican settings documentation

Plugins

Pelican provides a plugin architecture to allow extending and adding extra functionality. The central repository of pelican-plugins is available on github. I used the following plugins on my site:

  • pdf-img If an img tag contains a PDF, EPS or PS file as a source, this plugin generates a PNG preview which will then act as a link to the original file.
  • simple_footnotes Adds footnotes to blog posts
  • thumbnailer Creates thumbnails for all of the images found under a specific directory

The first plugin, pdf-img makes linking to PDF documents such as my CV a much nicer experience. I changed the code from the default in two ways:

  • Create a max-width setting. When I first used the plugin, the png images were produced full size and took up the whole screen. I added a setting so if the pdf width was more than 200px (configurable) the image would be reduced in size.
  • Create a default style setting. This overrides the default style for images within your article (but can be overridden itself by a style specified in the article). I then set the default style to 'border: 2px solid #AAA;'. This produced a gray boarder around my (mostly) white pdfs making them stand out from the white background.

Hopefully I will find time to create a couple of pull requests and get my changes included in the main code.

The second plugin, simple_footnotes, does what it says on the tin and worked well.

The third plugin, thumbnailer, I am less happy with. What I wanted was a simple method of linking to a picture using standard notation, have it reduce the image size in the article but link to the full size image. Thumnailer will reduce the size of the images, but currently I am having to link to the originals myself.

There may be another plugin that does this better but I did not find it during my quick research.

Go Top
Previous:
« New Site for 2016
Next:
What is a TAR »

Comments

I would love to know what you think. To comment on this article, send me an email

No comments yet.