Your app has gone haywire. The database is maxed out, you’re getting DDoSed, or you’re doing some server maintenance. Welp, gotta show something. You don’t want your site to have the default Nginx error page, right?

Unfortunately, you can’t rely on all the nice asset pipeline stuff you normally use. Your app’s dead, remember? So you have to have some totally static pages - html, images, and js you can serve that will get your message up, provide contact info, and hopefully make your users smile a little instead of grimacing so much. Not to worry, S3 has you covered.

But if you’ve got a few error pages, and they all have the same styles, updating them can be a pain. The solution is a static site generator, of which Jekyll is the go-to. So make a directory in your Rails app, say /jekyll, drop your static files in there, run the site generator and boom! You’ve got your static pages.

Then you need to upload them to S3. You also probably want all that stuff in /public as well, so your app can use them as fallback error pages. So here’s a quick Rake task which handles all that.

Then, when you want to update the styles, you can mess around with the pages, test using jekyll serve, and deploy with the rake task. Easy!

Bonus points:

  1. Set up a subdomain for serving static content, and set your S3 bucket permissions to act as a website.
  2. Use your new static site url on Heroku’s settings page for error & maintenance pages.