Getting Started with Rails2static

February 18, 2026 Getting Started

Rails2static turns your Rails app into a static site. You keep writing ERB templates, using ActiveRecord, and organizing code the Rails way — then generate plain HTML files you can deploy anywhere.

Installation takes about a minute. Add the gem to your Gemfile:

gem "rails2static"

Run bundle install, then generate the initializer:

rails generate rails2static:install

This creates config/initializers/rails2static.rb with sensible defaults. The most important option is exclude_patterns, which lets you skip routes that shouldn't be in the static output — like admin pages or anything behind authentication.

To generate your site, run:

rake rails2static

That's it. Your static site is now in the _site/ directory. You can preview it locally with:

rake static:preview

This starts a local server at http://localhost:8000 so you can verify everything looks right before deploying.

The key idea is that you develop your site exactly like any Rails app. Use migrations, seeds, scaffolds, partials, helpers — whatever you'd normally use. Rails2static just adds a build step that snapshots your app into static files.

← Back to all posts