Filters are modules that export their methods to liquid. All methods will have to take at least one parameter which represents the input of the filter. The return value will be the output of the filter.
module Jekyll
module AssetFilter
def asset_url(input)
"http://www.example.com/#{input}?#{Time.now.to_i}"
end
end
end
Liquid::Template.register_filter(Jekyll::AssetFilter)
For more details on creating custom Liquid Filters, head to the Liquid docs.
ProTip™: Access the site object using Liquid
Jekyll lets you access the
siteobject through the@context.registersfeature of Liquid at@context.registers[:site]. For example, you can access the global configuration file_config.ymlusing@context.registers[:site].config.
© 2025 Jekyll Core Team and contributors
Licensed under the MIT license.
https://jekyllrb.com/docs/plugins/filters/