Static sites are sites that don’t contain any dynamic server-side functionality or application logic. Examples include brochure sites made up completely of HTML and CSS or even interactive client-side games built in Flash that don’t interact with a server component. Though these sites only require a web-server to deliver their content to users it’s still useful to use a platform like Heroku to quickly provision and deploy to such infrastructure.

Using the Rack framework, static sites can be quickly deployed to Heroku.

Specify dependencies

Many dynamic applications require dozens of third-party libraries and frameworks to run. Static sites, however, require very little support from other libraries. In this case only the rack gem is required. In the Gemfile file add the following:

source 'https://rubygems.org'
gem 'rack'

and run the bundle command to download and resolve the rack dependency.

$ bundle install
Using rack (1.4.1)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

File server configuration

Rack must be told which files it should serve as static assets. Do this by editing the config.ru file so it contains the following:

Go to your browser and open http://localhost:9292 to see your static site loaded. As you make changes to the site you only need to reload your browser to view the changes – you don’t have to bounce the server.

Deploy to Heroku

Before deploying your site to Heroku you will need to store your code in the Git version control system which was installed for you as part of the Heroku CLI. When inside the site root directory execute the following commands: