Nanoc»Using common filters

This guide gives an overview of typical approaches for using common filters.

Using Sass

Sass is a CSS extension language that supports variables, mixins, partials, and more. To use Sass with Nanoc, create a rule that matches /**/*.sass, calls the :sass filter, and writes out a .css file:

compile '/**/*.sass' do
  filter :sass
  write item.identifier.without_ext + '.css'
end

If you prefer using the SCSS syntax for Sass, rather than the default Sass syntax, pass syntax: :scss to the :sass filter, and match on /**/*.scss rather than /**/*.sass:

compile '/**/*.scss' do
  filter :sass, syntax: :scss
  write item.identifier.without_ext + '.css'
end

For more information, see the :sass filter reference.

Using kramdown

kramdown is a fast and featureful Markdown processor. To use it with Nanoc, create a rule that matches /**/*.md and calls the :kramdown filter:

compile '/**/*.md' do
  filter :kramdown
  layout '/default.*'
  write item.identifier.without_ext + '.html'
end

The :kramdown filter can take options. For example, pass auto_ids: false to disable automatic header ID generation:

compile '/**/*.md' do
  filter :kramdown, auto_ids: false
  layout '/default.*'
  write item.identifier.without_ext + '.html'
end

For more information, see the :kramdown filter reference.