Enjoyable CMS using Statamic + GitHub + WebFaction

Joel ConfinoNews2 Comments

Statamic is a file-based content management system.  Inspired by Asana’s use of Statamic, I decided to check it out.  I’ve only been using it for a few hours this weekend, but I can see a lot of ways it could be useful beyond building a public blog.  I’m hooked.  To get an idea of what it is like to write content using Statamic, check out their screencast.  Things I like about it:

  • You write pages in Markdown
  • Your directories and files are the URLs
  • Because it is file-based, it can be easily versioned using Github or any other SCM.  This makes it useful for internal knowledge management (e.g. a wiki) especially when traceability is important.
  • Lightweight.  You can run it on any server with PHP.  No database required.
  • It is easy to create or customize your own template using the custom templating language.  Much nicer than hacking with WordPress templates.

My goal was to get Statamic up and running on a web host with the content in GitHub.  I also wanted to have hooks setup so if I committed a change to some content either through Github’s web-based file editor or via a normal git push that it would automatically publish my change.  Here are the steps I went through:

  1. Purchase and download Statamic.  It isn’t free but it is cheap: $29 for personal license, $99 for professional license.
  2. Sign up for a WebFaction account which costs $9.50 a month.  You can host it on any server that runs PHP so you’ve got a lot of options.
  3. Configure a new PHP web app using WebFaction’s documentation found here.
  4. Install and configure Statamic: unzip a zip file, set file permissions according to Statamic’s documentation here and Webfaction’s documentation here.
  5. Create a Git repo to hold your content.
  6. Delete the sample _content that comes with Statamic, and instead clone your Git repo in the _content directory.
  7. Create a GitHub web hook which invokes a URL you specify every time there is a commit.
  8. Create a simple PHP script that gets invoked by the GitHub web hook and does Git pull to get the latest content changes.  I used the one listed here.
  9. In order to prevent Git from prompting for a username/password every time the script is run, you need to set up a .netrc file in your home directory.  Bonus points if you encrypt the .netrc file or use regular SSH with public/private key pair.   You might also want to create a new Github account with read-only access to your repo for this which I did.  Info on how to create the .netrc file can be found here.

It will probably take you an hour or 2 to get it up and running which is really pretty quick.  The Haydle team will be experimenting with using Statamic as an internal wiki-like knowledge store, and maybe we’ll blog again in a couple of months to let you know how its going.  In the meantime, please tell us about your experiences with Statamic or other software that is both enjoyable to use and makes you more productive.