Hyper

Hyper is a dead simple, zero-config framework for static HTML websites. Use it to create small HTML sites with static content; host your site anywhere that supports Rack.

Quick Start

Five steps from install to a functioning website:

$ gem install hyper
$ hyper new my_website
$ cd my_website
$ bundle install
$ bundle exec rackup

Point your browser at 0.0.0.0:9292 and you'll see your website's home page.

Deployment

If you love Heroku, deployment is easy:

$ cd my_website
$ heroku create
$ git push heroku master

Any other rack-compatible host should work too.

Adding Content

To add content to your site, you just need to know two things:

  1. Shared content (stuff that goes on every page of your website) goes in templates/layout.html.erb
  2. Page-specific content goes in templates/views/{page}.html.erb

Put your navigation and header in layout.html.erb. Put the content for your about page in views/about.html.erb (link to the page using /about). It's that simple.

Also note: your home page content goes in views/index.html.erb; Hyper knows to map the root URL to that file.

Stylesheets, Images, Javascripts, Etc

Put your stylesheets, images, javascripts, etc in public: Hyper will handle the rest. When referencing these files in your HTML, drop the "public" from the path — public/images/logo.png should become <img src="/images/logo.png" />.

Helper Code

Put your custom helper methods in lib/helper.rb:

# in lib/helper.rb
module Hyper::Helper
  def the_time
    Time.now.to_s
  end
end

# in templates/layout.html.erb
<html>
  <head>
    <title>Clock</title>
  </head>
  <body>
    <h1>Hello! The time is <%= the_time -%></h1>
  </body>
</html>

Helper methods have access to a request object which is an instance of Rack::Request.

In-Depth

Hyper is intentionally simple. Once you've generated a new site, you'll get the following files and folders:

File/Folder Info
templates/layout.html.erb The layout for your website. Stuff that's the same on every page (header, navigation, etc) should go here
templates/views This is where your page-specific content lives. See "Adding Content" for more details
public Put your static assets here
config.ru Your site's rack config file. Customize your rack app here (if you don't know rack, just ignore this file)
Gemfile For use with Bundler

Defaults are set so you don't have to worry about anything outside templates if you don't want to. If you understand rack and want to add middleware, do that in config.ru — note that Hyper already knows to serve static content from public, so you don't need to use Rack::Static.

Author

I'm James Wilding and I make Ruby and Rails software.

License

Hyper is released under the MIT license.