All of the standard Liquid filters are supported (see below).
Rustyll adds several high-performance filters of its own, all of which you can find on this page. You can also create your own filters using plugins. Rustyll’s filter implementation is significantly faster than Jekyll’s, as they’re written in Rust rather than Ruby.
Description | Filter and Output |
---|---|
Relative URL Prepend |
|
Absolute URL Prepend |
|
Date to XML Schema Convert a Date into XML Schema (ISO 8601) format. |
|
Date to RFC-822 Format Convert a Date into the RFC-822 format used for RSS feeds. |
|
Date to String Convert a date to short format. |
|
Date to String in ordinal US style Format a date to ordinal, US, short format. 3.8.0 |
|
Date to Long String Format a date to long format. |
|
Date to Long String in ordinal UK style Format a date to ordinal, UK, long format. 3.8.0 |
|
Where Select all the objects in an array where the key has the given value. |
|
Where Expression Select all the objects in an array where the expression is true. 3.2.0 |
|
Find Return the first object in an array for which the queried attribute has the given value or return |
|
Find Expression Return the first object in an array for which the given expression evaluates to true or return |
|
Group By Group an array's items by a given property. |
|
Group By Expression Group an array's items using a Liquid expression. 3.4.0 |
|
XML Escape Escape some text for use in XML. |
|
CGI Escape CGI escape a string for use in a URL. Replaces any special characters with appropriate |
|
URI Escape Percent encodes any special characters in a URI. URI escape normally replaces a space with |
|
Number of Words Count the number of words in some text. |
|
Array to Sentence Convert an array into a sentence. Useful for listing tags. Optional argument for connector. |
|
Markdownify Convert a Markdown-formatted string into HTML. |
|
Smartify Convert "quotes" into “smart quotes.” |
|
Converting Sass/SCSS Convert a Sass- or SCSS-formatted string into CSS. |
|
Slugify Convert a string into a lowercase URL "slug". See below for options. |
|
Data To JSON Convert Hash or Array to JSON. |
|
Normalize Whitespace Replace any occurrence of whitespace with a single space. |
|
Sort Sort an array. Optional arguments for hashes 1. property name 2. nils order (first or last). |
|
Sample Pick a random value from an array. Optionally, pick multiple values. |
|
To Integer Convert a string or boolean to integer. |
|
Array Filters Push, pop, shift, and unshift elements from an Array. These are NON-DESTRUCTIVE, i.e. they do not mutate the array, but rather make a copy and mutate that. |
|
Inspect Convert an object into its String representation for debugging. |
|
Rustyll-specific Performance Filters
Rustyll adds several filters specifically designed for performance optimization:
Description | Filter and Output |
---|---|
Parallel Map Maps a collection in parallel across multiple CPU cores, providing significant performance improvements for large collections. |
|
Cached Caches the result of a filter chain for reuse, improving performance for expensive operations that are used multiple times. |
|
Optimized Sort A highly optimized sorting implementation that's significantly faster than the standard sort filter for large collections. |
|
Parallel Where Performs collection filtering in parallel for better performance on large datasets. |
|
Memoize Remembers the result of expensive operations for the duration of the build. |
|
Options for the slugify
filter
The slugify
filter accepts an option, each specifying what to filter.
The default is default
. They are as follows (with what they filter):
-
none
: no characters -
raw
: spaces -
default
: spaces and non-alphanumeric characters -
pretty
: spaces and non-alphanumeric characters except for._~!$&'()+,;=@
-
ascii
: spaces, non-alphanumeric, and non-ASCII characters -
latin
: likedefault
, except Latin characters are first transliterated (e.g.àèïòü
toaeiou
)
Rustyll’s implementation is significantly faster than Jekyll’s, particularly for large strings.
Detecting nil
values with where
filter
You can use the where
filter to detect documents and pages with properties that are nil
or ""
. For example,
// Using `nil` to select posts that either do not have `my_prop`
// defined or `my_prop` has been set to `nil` explicitly.
{% assign filtered_posts = site.posts | where: 'my_prop', nil %}
// Using Liquid's special literal `empty` or `blank` to select
// posts that have `my_prop` set to an empty value.
{% assign filtered_posts = site.posts | where: 'my_prop', empty %}
Binary operators in where_exp
filter
You can use Liquid binary operators or
and and
in the expression passed to the where_exp
filter to employ multiple
conditionals in the operation.
For example, to get a list of documents on English horror flicks, one could use the following snippet:
{{ site.movies | where_exp: "item", "item.genre == 'horror' and item.language == 'English'" }}
Or to get a list of comic-book based movies, one may use the following:
{{ site.movies | where_exp: "item", "item.sub_genre == 'MCU' or item.sub_genre == 'DCEU'" }}
Rustyll’s implementation of where_exp
includes advanced optimization techniques that make these expressions much faster than Jekyll’s Ruby implementation.
Filter Performance
Rustyll’s filters are implemented in Rust, providing several performance advantages:
- Native code execution: Filters run as compiled code, not interpreted Ruby
- Parallel processing: Many filters can operate in parallel
- Memory efficiency: Minimal memory overhead during filter operations
- Zero-copy operations: Data is processed without unnecessary duplication
- Optimized algorithms: Using highly efficient data structures and algorithms
For the best performance with large sites, consider using the Rustyll-specific parallel filters.
Standard Liquid Filters
For your convenience, here is the list of all Liquid filters with links to examples in the official Liquid documentation.