Mark Trapp

Jekyll Indentation Filter

This plugin provides a filter for indenting Liquid output. Based on the example plugin described in Mike Fulcher’s blog post, "Better Indentation for Injected Jekyll Content", this plugin solves the <pre> and <code> tag caveat mentioned in the blog post and incorporates a few code style changes and optimizations.


This plugin is provided as a gem:

gem install jekyll-itafroma-indent_filter

Once the gem is installed, include it in your Jekyll site's configuration:

gems: ['jekyll/itafroma/indent_filter']


Specify the number of spaces you’d like the output to be by using the indent filter:

{{ content | indent: 20 }}
<!-- content will be indented 20 spaces -->


This plugin is inspired the example provided in Mike Fulcher’s blog post, "Better Indentation for Injected Jekyll Content".

The <pre> and <code> indentation solution was inspired by kerotaa's remove-empty-lines-html.rb plugin.

Copyright and license

This plugin is copyright © 2013—2014 Mark Trapp. All rights reserved. It is made available via the MIT license. A copy of the license can be found in the LICENSE file.

Related links

Comments and feedback are welcome and appreciated. Need help on your next project? Let's talk.