I just wanted to walk through how I set this blog up - both as a How to for others and for posterity. If it isn't obvious yet, this blog is powered by Pelican (the version I'm using as of this writing in 3.3) and is hosted on Github pages. What isn't obvious yet is that, in the background, Dropbox is helping out too.
So the structure I ended up following was to create a new folder in my Dropbox folder - I called it gh-blog
. Once in this folder, I follow the following steps:
sudo pip install virtualenv virtualenvwrapper
// setup virtualenvwrapper
mkvirtualenv --no-site-packages gh-blog
pip install pelican Fabric
cd ~/Dropbox/gh-blog
pelican-quickstart // I mostly followed the defaults
After this, I had a 'base' pelican blog setup. I tried running fab build
followed by fab serve
and going to http://localhost:8000 but as expected, no blog posts were shown.
At this stage, I logged into github and created my public repository matching my username (rmanocha.github.com). Once this was done, I cloned this repository inside the gh-blog
folder:
cd ~/Dropbox/gh-blog
git clone git@github.com:rmanocha/rmanocha.github.com.git
Finally, I updated the fabfile (fabfile.py
) to make the newly cloned folder the output folder (this is required since the output folder is where all the HTML and CSS generated by pelican is stored; and this is what is required by github to render your blog). My final fabfile.py looks like:
from fabric.api import *
import fabric.contrib.project as project
import os
# Local path configuration (can be absolute or relative to fabfile)
env.deploy_path = 'rmanocha.github.com'
DEPLOY_PATH = env.deploy_path
GITHUB_REPO = 'git@github.com:rmanocha/rmanocha.github.com.git'
def clean():
if os.path.isdir(DEPLOY_PATH):
local('rm -rf {deploy_path}'.format(**env))
local('git clone %s' % GITHUB_REPO)
def build():
local('pelican -s pelicanconf.py -o {deploy_path} content'.format(**env))
def rebuild():
clean()
build()
def regenerate():
local('pelican -r -s pelicanconf.py')
def serve():
local('cd {deploy_path} && python -m SimpleHTTPServer'.format(**env))
def reserve():
build()
serve()
def preview():
local('pelican -s publishconf.py')
You will need to change the env.deploy_path
and GITHUB_REPO
variables above. I haven't yet cleaned up the preview
and regenerate
commands - I haven't really used them yet. As you will notice in the build
command above, the 'content' we're going to generate is going to be stored in the content
folder. So essentially, this is where all your blog posts will go.
After adding a new post within the content
folder, I ran fab rebuild
followed by a fab serve
. Browsing to http://localhost:8000 should now show you your new blog post. After making sure everything looked good, I just did the following:
cd ~/Dropbox/gh-blog/rmanocha.github.com
git add .
git commit -av -m "first blog post"
git push
Tada. I was now able to browse to http://rmanocha.github.io and see my freshly minted blog post.
This setup allowed me to store my raw, markdown formatted blog posts somewhere (I didn't want to pay for a github repository) that was backed up and (sort of) version controlled while still publishing the blog posts I wanted to, to github. So far, things seem to be working smoothly.