Migrating from Octopress to Pelican: Part 1

Introduction

This week I am migrating from Octopress to Pelican.

I will post my notes here in 2 parts. This first part will simply focus on getting pelican setup with a barebones pelican site. I am deploying with Amazon S3, so if you are using a different host you'll have to refer to some of the other guides.

The 2nd part, which should follow on the weekend, will focus on adding in the extras, such as themes and social widgets.

This week's exercise took 2 hours. So if you are switching set aside approximately that much time after doing initial reading.

Bear with me while this site is under renovation!

Setup venv

This is what I needed to do with ruby's rbenv in order not to have broken octopress. Alas. Here I'm using one of virtualenvwrapper's functions, which sets up a virtualenv for python, and a project directory where I'll put site content and configs. I will also version control the project directory with git.

mkproject -p /usr/bin/python2.7 8888-88-88_website/jothamcity_pelican

Install requirements

Install the pelican package and use its quickstart command line program to setup some configurations. Go through the steps carefully.

pip install pelican
pelican-quickstart
ls

content/ markdown site content

output/ generate html

Makefile make commands for building and pushing content

develop_server.sh Script to run a dev server to view your content

pelicanconf.py Pelican settings

publishconf.py Publishing settings

Build test site

I recommend using the Makefile if your on a unix-like system for local server management. This provides a convenient way to view and automatically regenerate the site content when source changes.

make devserver
#go preview your site at http://localhost:8000/
./develop_server.sh stop

Check out publishing configuration

Let's take a look at the default configurations provided by running pelican-quickstart. Take note of where changes will be needed, e.g. timezone, etc.

cat ~/projects/8888-88-88_jothamcity/publishconf.py

...

#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals

# This file is only used if you use `make publish` or
# explicitly specify it as your config file.

import os
import sys
sys.path.append(os.curdir)
from pelicanconf import *

SITEURL = 'http://jotham-city.com'
RELATIVE_URLS = False

FEED_ALL_ATOM = 'feeds/all.atom.xml'
CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'
DELETE_OUTPUT_DIRECTORY = True

Note the category feeds atom. I'll have to update my r-bloggers syndication reference.

cat ~/projects/8888-88-88_jothamcity/pelicanconf.py

...

#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals

AUTHOR = u'Jotham Apaloo'
SITENAME = u'Jotham City'
SITEURL = ''

PATH = 'content'

TIMEZONE = 'Europe/Paris'

DEFAULT_LANG = u'en'

# Feed generation is usually not desired when developing
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None

# Blogroll
LINKS = (('Pelican', 'http://getpelican.com/'),
         ('Python.org', 'http://python.org/'),
         ('Jinja2', 'http://jinja.pocoo.org/'),
         ('You can modify those links in your config file', '#'),)

# Social widget
SOCIAL = (('You can add links in your config file', '#'),
          ('Another social link', '#'),)

DEFAULT_PAGINATION = False

For brevity, I will skip sharing the whole Makefile. You can see its functions with make help.

Check out themes

pelican-themes -l

Nothing ground breaking. I Will go looking for something new in part 2.

Setup s3 deployment

The bucket name was setup in pelican-quickstart step. Here is the steps to configuring the s3cmd options so you can actually push to the bucket. So I will try deploying. this will take down the octopress version of jotham-city.com :(.

I enabled versioning on my s3 bucket before this so I could recover if disaster strikes.

pip install s3cmd
s3cmd --configure
make s3_upload
# configuration saved in ~/.s3cfg

Setup git

This is a good time to begin tracking the project.

cd ~/projects/8888-88-88_jothamcity
git init
touch .gitignore
echo "*.pyc*" >> .gitignore
echo "cache/*" >> .gitignore
echo "output/*" >> .gitignore
git add .
git commit -m 'first commit, everything operational'

Configure some settings for consistency with the octopress

Put the following in pelicanconf.py. This is for disqus compatibility with older posts which I will migrate here.

ARTICLE_URL = 'blog/{date:%Y}/{date:%m}/{date:%d}/{slug}/'
ARTICLE_SAVE_AS = 'blog/{date:%Y}/{date:%m}/{date:%d}/{slug}/index.html'

# We'll use this one later
STATIC_PATHS = ['images', 'notebooks', 'downloads']

Test post

pip install markdown
touch ~/projects/8888-88-88_jothamcity/content/migrating-from-octopress.markdown

In there add content according to the http://docs.getpelican.com/en/3.5.0/content.html.

Part 2 preview

Next time I'll look at

  • Adding a license
  • Migrating pages
  • Migrating posts
  • Changing themes
  • etc

Ended up skipping plugings and zsh completion (which doesn't exist for pelican as far as I know could find)

Go Top
comments powered by Disqus