data scientist, biophysicist, mac-unix zealot, pythonista

My Octopelican Python Blog

Many have asked about my blog design and how I incorporate IPython notebooks, such as the one used in the previous post. I merely glued all the pieces together for this setup, so to give credit where it is due and to provide a documented how-to for my future self, I've described both blog design and incorporating IPython notebooks into posts.

My desire for this blog has always been to have a platform for sharing useful and sometimes interesting information related to my research and to provide an opportunity to learn, which for me means tinkering. As someone who does not have extensive knowledge of CSS or other web-centric languages, I knew I wanted to use a template-based solution rather than coding a website from scratch. However, the inevitable desire to tinker meant that browser-based template options, such as those offered by Wordpress and Blogger, wouldn't suffice. Solutions that compile templates locally, such as Octopress, allow more customization and, thus, seemed like a good option. The downside of Octopress is that it uses ruby, which I don't know. After more searching, I discovered Pelican, which works similarly to Octopress but is written in my beloved Python. Having a blogging engine that speaks the same language as the topic of much of the content I envisioned posting seemed like a natural solution.

After settling on a blogging solution, I had to find a Pelican-based template. Having browsed many Octopress blogs, I developed an affinity for the default template used by this engine. Fortunately, a kind soul had converted the Octopress template to Pelican and shared it. Since I prefer lighter tones for websites and the default format of this template is quite dark, I wanted to modify it. I found an excellent tutorial by Aijaz Ansari on customizing this theme within Octopress and was able to apply these changes directly because the CSS portion of this template is identical to the Pelican version. These theme modifications are based on SASS, so I did need to break out my ruby chops to compile1 the modified theme into CSS2.

The last step was adding the ability to insert IPython notebooks in blog posts. Fortunately, Jake Vanderplas recently posted about doing so in Pelican. He even created a Pelican extension, called liquid tags, capable of inserting an IPython notebook referenced in a markdown post. If you go this route, please be aware that liquid tags is very new--as of the writing of this post, it is still a pull request on GitHub. Furthermore, liquid tags depends on nbconvert, an IPython utility for converting notebooks to html and other formats, which itself is currently being rewritten. Thus, any efforts in this area will likely have to be duplicated again in the future once these packages stabilize. For the fearless, I have described the installation in more detail here.

  1. This requires installation of the compass ruby gem. Once installed, the CSS is compiled by running compass compile from the top directory of the theme (where config.rb is located). The compiled file is created in static/css/main.css of the theme and will be copied to the correct directory upon blog generation with pelican. 

  2. The compiled CSS file used for this blog can be downloaded here