4
votes

I must be off my game today because I can't even see where the handleize filter is even defined. It's in the Shopify documentation, and it works when I use it in my templates. However I can't see the source code for it, so I can't find out how to call it from my plugin.

Also note that while these two questions are similar, the answers do not apply here because handleize is not defined in either of the source modules mentioned.

If it matters, I'm using Jekyll 2.1.1 and Liquid 2.6.1.

4

4 Answers

7
votes

For anyone else who stumbles across this, from Jekyll version 2.4.0 onward, you can use the built-in slugify filter, which basically does what handleize does.

3
votes

OK turns out that the Shopify documentation is not correct; some of the documented filters, including handleize are not available from within a standard Jekyll install. The Jekyll core team is aware of the documentation issues and is working towards fixing them.

Also note that liquid does not seem to flag any errors or warnings when using an unknown filter. Hence you may (as I did) think that the filter "works" when in fact it is silently being ignored.

1
votes

Here's my work around for not being able to use handleize:

{{ post.title | replace: ' ', '_' }}
0
votes

To also get the downcased result:

{{ post.title | replace: ' ', '_' | downcase }}

or simply

{{ post.title | slugify }}