Tips

Here are some tips about Pelican that you might find useful.

Publishing to GitHub

GitHub comes with an interesting “pages” feature: you can upload things there and it will be available directly from their servers. As Pelican is a static file generator, we can take advantage of this.

User Pages

GitHub allows you to create user pages in the form of username.github.com. Whatever is created in the master branch will be published. For this purpose, just the output generated by Pelican needs to pushed to GitHub.

So given a repository containing your articles, just run Pelican over the posts and deploy the master branch to GitHub:

$ pelican -s pelican.conf.py ./path/to/posts -o /path/to/output

Now add all the files in the output directory generated by Pelican:

$ git add /path/to/output/*
$ git commit -am "Your Message"
$ git push origin master

Project Pages

For creating Project pages, a branch called gh-pages is used for publishing. The excellent ghp-import makes this really easy, which can be installed via:

$ pip install ghp-import

Then, given a repository containing your articles, you would simply run Pelican and upload the output to GitHub:

$ pelican -s pelican.conf.py .
$ ghp-import output
$ git push origin gh-pages

And that’s it.

If you want, you can put that directly into a post-commit hook, so each time you commit, your blog is up-to-date on GitHub!

Put the following into .git/hooks/post-commit:

pelican -s pelican.conf.py . && ghp-import output && git push origin gh-pages
Fork me on GitHub