Fork me on GitHub

Running nanoc on Heroku

Intrigued by the recent rise in popularity of the nanoc library, I decided to start porting my homepage over from Rails to using nanoc. However I wasn't too sure what would be the best way to push my site to Heroku. nanoc comprises of a folder that contains your site configuration, layout, content and the static output from the website.

I did initially think about putting a Git repository in the output folder and simply pushing the output folder to Heroku. What about my layouts and content though? Do I put them under a separate repository? It felt overkill to use two repositories for one website.

I then found this post by Jamie Iniesta that describes how he created the Euruko 2009 site using nanoc. Towards the end of the post, Jamie describes how he used a Rack configuration file to determine how files should be served from the site's nanoc folder.

Instead of pushing just the output folder, I could now push the my whole nanoc folder as one repository and serve only the files from the output folder for my homepage.

Using a Rack configuration file, we redirect incoming requests for pages to include the standard index.html that all pages in nanoc are called, and then use Rack::Static to tell Heroku that we want to serve all static assets from the root of the output folder.

We also include an empty app at the bottom should there be any problems with the site.

nanoc has been a great little library to use for generating a static site and the ability to push to Heroku makes deployment so easy. I've only managed to scratch the surface with nanoc though but I'm looking to add more content to my homepage over the next few months so that I can dig deeper into using nanoc.

 

Snippets #131

Happy Whyday everyone!

  • Heroku Plus - Allows you to use multiple Heroku accounts from the command line.
  • Ruby 1.9.2 released - Hot on the heels of the latest updates to 1.8.7 and 1.9.1, the newest version of Ruby provides lots of great new features.

Snippets #121

Snippets #114

TDD skills are definitely picking up thanks to a mix of Shoulda and Factory Girl.

  • Rails 3 Beta 4 on Heroku - I'm still going to wait for an official release of Rails 3 before I start updating some applications.
  • ExtJS/Rails CRUD Application in 7 minutes - A good idea if your building an admin section for your Rails application, but for anything else I think I would stick to using my own preferred gems and libraries for some of these features.

Snippets #96

Lots of goodies today!