Middleman makes developing stand-alone websites simple. The last few years has seen an explosion in the amount and variety of tools developers can use to build web applications. Ruby on Rails selects a handful of these tools:
- Sass for DRY stylesheets
- Sprockets for combining and minifying assets
- ERb & Haml for dynamic pages and simplified HTML syntax
Middleman gives the stand-alone developer access to all these tool and many, many more. Why would you use a stand-alone framework instead of Ruby on Rails?
These days, many websites are built with an API in mind. Rather than package the frontend and the backend together, both can be built and deployed independently using the public API to pull data from the backend and display it on the frontend. Static websites are incredibly fast and require very little RAM. A front-end built to stand-alone can be deployed directly to the cloud or a CDN. Many designers and developers simply deliver static HTML/JS/CSS to their clients.
Middleman is built on Ruby and uses the RubyGems package manager for installation. These are usually pre-installed on Mac OS X and Linux. Windows users can install both using RubyInstaller.
gem install middleman
Once Middleman is installed, you will have access to the
middleman command. First, let's create a new project. From the terminal:
middleman init MY_PROJECT
This will create a new Middleman project located in the "MY_PROJECT" directory. This project contains a
config.rb file for configuring Middleman and a
Change directories into your new project and start the preview server:
cd MY_PROJECT middleman server
The preview server allows you to build your site, by modifying the contents of the
source directory, and see your changes reflected in the browser at:
source directory. When you're ready to use more complex templates, simply add the templating engine's extension to the file and start writing in that format.
For example, say I am working on a stylesheet at
source/stylesheets/site.css and I'd like to start using Compass and Sass. I would rename the file to
source/stylesheets/site.css.scss and Middleman will automatically begin processing that file as Sass. The same would apply to CoffeeScript (
.js.coffee), Haml (
.html.haml) and any other templating engine you might want to use.
Finally, you will want to build your project into a stand-alone site. From the project directory:
config.rb file to see some of the most common extensions which can be activated.
A full set of in-depth instructional guides are available on the official website at:
The community maintains its own collection of tips and tricks in the GitHub wiki:
Finally, up-to-date generated code documentation is available on RubyDoc: http://rubydoc.info/github/middleman/middleman
The official community forum is available at:
GitHub Issues are used for managing bug reports and feature requests. If you run into issues, please search the issues and submit new problems:
The best way to get quick responses to your issues and swift fixes to your bugs is to submit detailed bug reports, include test cases and respond to developer questions in a timely manner. Even better, if you know Ruby, you can submit Pull Requests containing Cucumber Features which describe how your feature should work or exploit the bug you are submitting.
- Checkout Repository:
git clone https://github.com/middleman/middleman.git
- Install Bundler:
gem install bundler
bundle installinside the project root to install the gem dependencies.
- Run test cases:
bundle exec rake test
Copyright (c) 2010 Thomas Reynolds. MIT Licensed, see LICENSE for details.