the further adventures of

Mike Pirnat

a leaf on the wind

« Previous Post Next Post »

How I Deploy My Blogofile Blog on Webfaction

This is partly to help anyone else, but mostly so I don't forget...

Installing Git

Before you do anything, you'll need some git binaries, since they aren't yet installed by default on Webfaction. See Webfaction's git setup docs for how to do this.

Make a Webapp

Use Webfaction's panel to create a new static html web app (assume we'll call it "my_blog").

Making Directories

A little directory setup will be nice:

mkdir $HOME/src
mkdir $HOME/src/my_blog.git
mkdir $HOME/tmp
mkdir $HOME/tmp/my_blog

Getting & Installing Blogofile

I'm a nerd/Blogofile contributor, so I like to roll with the head of the repo.

In my case, I'm getting my own personal fork:

git clone $HOME/src/blogofile
cd $HOME/src/blogofile
python2.6 develop

You'll want to do this on Webfaction and on your local machine (so that you can do offline builds to test).

Initializing the Repo

cd $HOME/src/my_blog.git
git init --bare

Clone it Down

On your local machine:

git clone ssh://username@yourdomain/~/src/my_blog.git

On Webfaction:

git clone ~/src/my_blog.git ~/tmp/my_blog

(After all, we need somewhere to automatically freshen and build from!)

Init the Blog


cd my_blog
blogofile init simple_blog
git add _controllers _filters index.html.mako _posts _templates
git commit -m "Initial checkin of new blog"

First Push

Git really wants a branch to push into, and we don't have one of those yet. Just doing git push will cause git to shit its pants. So instead we have to do the oh-so-obvious:

git push origin master

Did that work?

Create Post-Receive Hook

On Webfaction:

cd $HOME/src/my_blog.git/hooks
vim post-receive

My (very basic!) post-receive hook looks like this:



unset GIT_DIR
git pull
blogofile build -v && rsync -a --delete-after $SITE_DIR $DEPLOY_DIR

This makes sure that:

  1. We get a fresh copy of the blog source
  2. We don't build inside our live site (in case anything goes wrong!)
  3. We don't rsync if the build died
  4. We sync all our changes into place and remove anything that we shouldn't have any more

TODO: I really, really, really need to rearrange this so that we don't do the build at all if the build area's checkout (in ~/tmp/my_blog) was up to date/didn't get any changes. Maybe not a big deal for everybody, but I've got like 1400 blog entries and it takes a while to regenerate all that HTML. I mostly dislike shell scripting, so I will probably write a small amount of Python here at some point.

Also it would probably be good to check any new/changed _posts items to see if they are drafts, because again it sucks to do a bunch of work that we don't have to. Hmm...

Compose a New Post


cd my_blog
vim _posts/hello-world.markdown

Push It!


git add _posts/hello-world.markdown
git commit -m "First post, woot"
git push

And hopefully it all Just Works!

  1. git pushes to remote repo
  2. post-receive hook fires
  3. tmp checkout is freshened
  4. blog is rebuilt
  5. blog is rsynced into place

Write Compelling Content

Now it's time to crank out that undying prose that will forever change the world... get to it!

blog comments powered by Disqus

« Previous Post Next Post »