Welcome to my blog!
In this first post I go quickly through the reasons why I use Pelican for my website, and the steps I did to get it going (on a Ubuntu 14.04 machine). (This will mainly help me to remember how I did it the first time, in case I have to do it again.)
My website was since a couple of years a very simple site, with barely more than a contact form on it. I used and still use the domain mainly for emailing purposes. However, I wanted to add a possibility to easily publish some blog posts. With easily I mean without any PHP or database (MySQL and friends) dependencies, just plain old html-files. That is where my online search found Pelican, a static website generator written in python. And as I am used to python, I was sold pretty quick.
Here are the steps I did, without too many explanations. If you don’t have
virtualenv installed, run
$ sudo apt-get install python-virtualenv
and then create the directory for your blog, here
~/myblog. Move into
this directory, and initiate a virtual environment.
$ mkdir ~/myblog $ cd ~/myblog $ virtualenv env
You have now a directory
env, where the local python install is located.
I then added the following two aliases to my
alias ablog='source ~/myblog/env/bin/activate && cd ~/myblog' alias dblog='deactivate'
ablog in the terminal will now activate the virtual environment
(indicated by a
(env) in the terminal) and move to the blog directory;
dblog will de-activate it again. So run
ablog, and we install some
additional packages and finally run
pip freeze, so we could later easily
re-install everything again.
(env)$ pip install pelican Markdown typogrify (env)$ pip freeze > requirements.txt
If you ever have to install it again, you can simply run
(env)$ pip install -r requirements.txt
which will install all packages at once (in this case,
typogrify; but you might have more).
Finally, run through the quick-start process, and you’re done!
My provider does not provide ssh-access, unfortunately, only FTP. To easily
deploy my content, I set up
$ sudo apt-get install lftp
To always force a secured connection, create a file
~/.config/lftp/rc, and put
set ftp:ssl-auth "TLS" set ftp:ssl-force yes
My passwords tend to be overly complicated, so I do not want to type it every
time. You can put a bookmark
“Password in plain text!”, you might shout. True. But if somebody has physical access to my laptop I have much bigger problems than that… Furthermore, this password is only for my blog-directory on the server, not for the entire server.
The final step is to adjust the Makefile:
ftp_upload: publish lftp myblog -e "mirror -R $(OUTPUTDIR) $(FTP_TARGET_DIR) ; quit"
The only thing I have to do after writing a new post is
(env)$ make ftp_upload
This will create the entire website, and deploy it subsequently. Oh yes, and the beauty of pelican is that you can write your posts in Markdown, so once everything is set up, you can forget about html.
After the initial set-up I
wasted invested too much time into
building my own theme, which you can grab from my
GitHub page. If you want to use it go and grab
it, put it in your
myblog directory, and then install it via
(env)$ pelican-themes --install ~/myblog/dashof
If you are interested in doing the same, use the power of search engines! Pelican is established enough, you will find plenty of more detailed tutorials out there. Go to the pelican website, look at their repo page, or read the excellent documentation. You will find many themes out there; a collection is available on the pelican-themes repo. Duncan Lock wrote a particularly nice, more detailed blog post on how to set-up your own blog with pelican (and about the advantages of a static site generator); it kick-started my pelican experience!
The only thing I have not yet tested is to use an IPython notebook to write posts. That comes next, I saw there is a plugin ready for that.
I use Pelican 3.3 (which was the newest stable version when I started), which has a bug when running a dev-server. Applying this patch solved the issue.