Skip to content
A HTML whitespace minifier for Middleman
Ruby Gherkin HTML PHP
Branch: master
Clone or download
Latest commit 22fb636 Jun 16, 2015
Type Name Latest commit message Commit time
Failed to load latest commit information.
features Fix support for passing options to Rack gem. Closes #20 May 12, 2014
fixtures/basic-app unvendor htmlcompressor, bump the dep and move to a v3 MM extension. May 5, 2014
lib Prep Jun 15, 2015
.gitignore Depend on pure ruby htmlcompressor May 24, 2012
.travis.yml v4 test May 2, 2015
Gemfile v4 test May 2, 2015
Gemfile-v3 v4 test May 2, 2015 chmod -x May 20, 2013 Update the default options Jun 14, 2015
Rakefile unvendor htmlcompressor, bump the dep and move to a v3 MM extension. May 5, 2014
middleman-minify-html.gemspec Bump dep Jun 1, 2015


middleman-minify-html is an extension for the Middleman static site generator that minifies whitespace around HTML via Htmlcompressor.


If you're just getting started, install the middleman gem and generate a new project:

gem install middleman
middleman init MY_PROJECT

If you already have a Middleman project: Add gem 'middleman-minify-html' to your Gemfile and run bundle install


activate :minify_html

The various options can be passed with a block or as a hash like so:

activate :minify_html, remove_input_attributes: false

These are the default settings, as listed in the Htmlcompressor documentation:

activate :minify_html do |html|
  html.remove_multi_spaces        = true   # Remove multiple spaces
  html.remove_comments            = true   # Remove comments
  html.remove_intertag_spaces     = false  # Remove inter-tag spaces
  html.remove_quotes              = true   # Remove quotes
  html.simple_doctype             = false  # Use simple doctype
  html.remove_script_attributes   = true   # Remove script attributes
  html.remove_style_attributes    = true   # Remove style attributes
  html.remove_link_attributes     = true   # Remove link attributes
  html.remove_form_attributes     = false  # Remove form attributes
  html.remove_input_attributes    = true   # Remove input attributes
  html.remove_javascript_protocol = true   # Remove JS protocol
  html.remove_http_protocol       = false  # Remove HTTP protocol
  html.remove_https_protocol      = false  # Remove HTTPS protocol
  html.preserve_line_breaks       = false  # Preserve line breaks
  html.simple_boolean_attributes  = true   # Use simple boolean attributes
  html.preserve_patterns          = nil    # Patterns to preserve

Build & Dependency Status

Gem Version Build Status Dependency Status Code Quality


The official community forum is available at:

Bug Reports

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.

How to Run Cucumber Tests

  1. Checkout Repository: git clone
  2. Install Bundler: gem install bundler
  3. Run bundle install inside the project root to install the gem dependencies.
  4. Run test cases: bundle exec rake test


Click here to lend your support to Middleman


Copyright (c) 2012-2014 Thomas Reynolds. MIT Licensed, see LICENSE for details.

You can’t perform that action at this time.