Provides multiple build targets and tools for Middleman.

gem install middleman-targets -v 1.0.13


middleman-targets readme

Gem Version


: This gem provides the ability to generate multiple targets by outfitting Middleman with additional command line options. The provided helpers make it simple to control content that is specific to each target, based on the target name or based on feature sets for each target.

It is standalone and can be used in any Middleman project.

Install the Gem

Install the gem in your preferred way, typically:

gem install middleman-targets

From git source:

rake install


The complete documentation leverages the features of this gem in order to better document them. Having installed the gem, read the full documentation in your web browser:

middleman-targets documentation
cd middleman-targets-docs/
bundle install
bundle exec middleman server

And then open your web browser to the address specified (typically localhost:4567).

Quick Documentation

Middleman 4.1.6 or newer is required. Earlier point versions of Middleman do not have the necessary support for this extension.

Once setup and configured, you can build multiple targets like so:

bundle exec middleman build --target mytarget


bundle exec middleman build_all


bundle exec middleman serve --target mytarget

Added Features

To support multiple targets and features, flexible configuration and helpers are available, including

  • Enhanced image_tag support chooses target-specific assets for you.
  • Enhanced image_tag support conditionally includes assets specific to targets or features that you designate.
  • The target_name?() helper allows you to selectively include or exclude content on a per-target basis.
  • The target_feature?() helper allows fined-grained control over included content by managing features of a target instead of a target per se.
  • Front matter target and exclude arrays can ensure entire pages are included or excluded on a target and/or feature specific basis.
  • …and more.

Rake Tasks

Run tests:

rake test

Generate YARD documentation:

rake yard


This Middleman extension is a critical part of Middlemac, the Mac OS X help building system for Mac OS X applications. However this gem is not Mac OS X specific and can be useful in any application for which you want to generate multiple targets.


MIT. See


See for point changes, or simply have a look at the commit history for non-version changes (such as readme updates).