URL Filters
These filters are used for manipulating and generating URLs in Liquid templates. They help build query strings, create anchor elements, generate thumbnails, and encode or decode URLs. Use these filters to manage links, images, and URL parameters dynamically in your templates.
build_query
Merges given query to current query.
Input
{{ product | link | build_query: "width=32&height=45" }}
Output
https://www.mystore.com/products/my-product?width=32&height=45
link_to
Shorthand for creating a anchor element.
Input
{{ "Start your trial now!" | link_to: "https://finqu.com" }}
{{ "Start your trial now!" | link_to: "https://finqu.com", "Visit finqu.com", "_blan" }}
Output
<a href="https://finqu.com">Start your trial now!</a> <a href="https://finqu.com" title="Visit finqu.com" target="_blank">Start your trial now!</a>
thumb
Creates a thumbnail from given image. Supports only images that are hosted by Finqu or Unsplash. You set a custom size with a parameter or select one from predefined size constants.
Constant | Size |
---|---|
pico | 16x16 |
icon | 32x32 |
thumb | 50x50 |
small | 100x100 |
compact | 160x160 |
medium | 240x240 |
large | 480x480 |
Input
{{ product.image | thumb:'icon' }}
{{ product.image | thumb:'240','400' }}
{{ product.image | thumb:'240, 400' }}
Output
https://images.finqu.com/sgfbHn2OZSwTzVwAoCvT6LJrYHstpb4FEZD6VXMLP2VtRiXG/image_32_32.png
https://images.finqu.com/sgfbHn2OZSwTzVwAoCvT6LJrYHstpb4FEZD6VXMLP2VtRiXG/image_240_400.png
https://images.finqu.com/sgfbHn2OZSwTzVwAoCvT6LJrYHstpb4FEZD6VXMLP2VtRiXG/image_240_400.png
url_decode
Decodes a string that has been encoded as a URL.
Input
{{ "%27Stop%21%27+said+Fred" | url_decode }}
Output
'Stop!' said Fred
url_encode
Converts any URL-unsafe characters in a string into percent-encoded characters.
Input
{{ "john@liquid.com" | url_encode }}
Output
john%40liquid.com
Last updated on