Titleize Gem Plugin Example
This site is a work-in-progress. Some of the information is incomplete and may not work as described. See the homepage for details.
Instead of writing your own title case plugin, why not use an existing gem? Grant Hollingworth has written a titleize gem which works well, so all we’d need to do is register a Liquid filter to use it in our Jekyll project.
First add the gem you wish to use in your Gemfile. Then build your plugin.
require 'titleize'
module Jekyll
module Titleize
def titleize(title)
title.titleize
end
end
end
Liquid::Template.register_filter(Jekyll::Titleize)
Inside the above titleize() method, we’re calling .titleize from the titleize gem and returning it via the Liquid filter, like this:
{{ page.title | titleize }}