Launching Middleman on Heroku

Login to Access Code

Middleman is awesome for building static sites, and heroku is awesome for hosting just about everything. The problem is, that the two do not really play nice together without the proper setup, and that setup is not well documented anywhere. We are going to create a vanilla middleman project and deploy it to heroku in a few easy steps.

Creating the Middleman Application

Like Rails and many other frameworks, the middleman gem comes with an executable that will allow you to quickly create a project based on the framework. Let’s utilize that and create a middleman application called middleman-heroku by opening terminal and entering the following:

middleman init middleman-heroku

Now we should make this project into a proper git repository:

cd middleman-heroku
git init

Creating a Heroku Application

Assuming you already have the heroku toolbelt installed, this is also super easy and should return an app name and url on success:

heroku create

Now that we have a vanilla application for both, let’s make the tweaks necessary to deploy our middleman app on heroku. First we need to add support for multiple buildpacks on heroku:

heroku config:add BUILDPACK_URL=

The Heroku Multi Buildpack allows us to specify multiple buildpacks for our app. It’s not absolutely necessary, but when using buildpacks, it is a good way to be future proof. Now that we have that installed, lets go and create a .buildpacks file and paste in the following buildpacks:

Now commit your changes, push to heroku, and open your newly-launched middleman website. No local building needed!

git add .
git commit . -m "heroku buildpacks for middleman"
git push heroku master
heroku open

Let us know if you run into any trouble or if this works well for your existing projects.