This blog uses Pelican for a few months now, And I feel fine with it. I feel writing easier, eventhough there is some constraints (but, what is perfect ? Wordpress had also its bad habits).

During migration, I tried to make everything works the same as previously, under wordpress.

So, articles’ address have the same syntax, which I like : /year/month/day/name-lang/ .

ARTICLE_URL 		= "{date:%Y}/{date:%m}/{date:%d}/{slug}-{lang}/"
ARTICLE_SAVE_AS 	= "{date:%Y}/{date:%m}/{date:%d}/{slug}-{lang}/index.html"
ARTICLE_LANG_URL 	= "{date:%Y}/{date:%m}/{date:%d}/{slug}-{lang}/"
ARTICLE_LANG_SAVE_AS 	= "{date:%Y}/{date:%m}/{date:%d}/{slug}-{lang}/index.html"

DAY_ARCHIVE_SAVE_AS 	= "{date:%Y}/{date:%m}/{date:%d}/index.html"
MONTH_ARCHIVE_SAVE_AS 	= "{date:%Y}/{date:%m}/index.html"
YEAR_ARCHIVE_SAVE_AS 	= "{date:%Y}/index.html"

The only bad side is that articles are now mainly bilingual (and soon trilingual). There is so, my first wish of custom'.

Plugin Lang-Category

I setted up my address for theme to indicate article’s lang at the end of name. But I wanted also to have one page per language. Pelican has an RSS or ATOM feed in its configuration, but no HTML side.

I, so, made a request for some modification, which would allow create a list of articles according to language, the exact behavior as a category. This request had been refused by Pelican’s developpers, but one wrote a plugin.

Conf’ : LANGUAGE_URL = ‘{lang}/index’ LANGUAGE_SAVE_AS = ‘{lang}/index.html’

I, now, have the following url :

It all works fine, apparently the same way as Polylang plugin from wordpress used to. And RSS links are the same, which means that normaly, my followers don’t even have to change their conf'.

I, at the same time, customized my Pelican theme to use the new plugin.

Theme

The theme is dev-random by Sam Hocevar, which I customized for my purposes.

My version is published here : dev-random3.

I added, from the begining, the links widget, which doesn’t exists in the orignal theme, and a 404 error page. I also slightly modified fonts and colors in the text.

To add links in the widget, you have to include this tuple in your configuration file and add or remove links in :

LINKS =  (('http://www.22decembre.eu','22decembre'),  
('http://getpelican.com/','Pelican'),  
('http://python.org/','Python.org'),  
('http://jinja.pocoo.org/','Jinja2'),  
…  
('http://blog.chown.me/','Vigdis'),  
('http://www.blog-libre.fr/','Cyrille Borne & co'),  
('http://maniatux.fr/','Maniatux'),)

When we began talking about the plugin, I adapted the theme with the language widget, which indicate the list of available languages.

It’s, sadly, not really optimal yet. Configuration is done manually in the pelicanconf.py :

# ((code, native_name, url),)  
LANGUAGES= (('fr','french','fr/'),  
    ('en','english','en/',),)

Conf’ Nginx

If you want to have a powerful blog, you need, at one time or another, to go to the webserver conf’. Here, it’s Nginx, which is super for static files.

# rss.xml is the name of the rss feed
# when querying the feed in the wordpress way, (http://…/feed/), people will actually get this file
index index.html rss.xml;

error_page 404 /404.html;
location  /404.html {
	internal;
}

# Where you put your files to dowload, if you have some.
# That way, no need to generate or maintain a page.
location ~* ^/downloads/ {
	autoindex on;
}

# Same there
location ~* ^/drafts/ {
	autoindex on;
}

# Article's name fails
location ~* ^/([0-9]+)/([0-9]+)/([0-9]+)/(.+)/$ {
	try_files $uri $uri/ /$1/$2/$3/;
    }

# day fails
location ~* ^/([0-9]+)/([0-9]+)/([0-9]+)/$ {
	try_files $uri $uri/ /$1/$2/;
    }

# months fails
location ~* ^/([0-9]+)/([0-9]+)/$ {
	try_files $uri $uri/ /$1/;
    }

# year fails
location ~* ^/([0-9]+)/$ {
	try_files $uri $uri/ /;
    }

Future Adaptations

I hope to continue improve theme and plugin, by providing, for example, automatic list of languages, and list of pages in a specific language.