Zone filters
Filters transform a value: string, number, money, array, media and URL filters.
This page is not hand-written: it is generated from the Zone engine's registry. Every name listed here actually works in the engine.
Summaries come straight from the source specification. Some summaries, syntax and examples are generated from MIT-licensed open specification data. Third-party licence notice
abs
Returns the absolute value of a number.
Returns: number
number | abs{{ -3 | abs }}append
Adds a given string to the end of a string.
Returns: string
string | append: string{%- assign path = product.url -%}
{{ request.origin | append: path }}article_img_urlDeprecated
Returns the CDN URL for an article's image.
Returns: string
variable | article_img_url| Parameters | Type | Required | Description |
|---|---|---|---|
size | string | No | The desired image size. |
{{ article.image | article_img_url }}{{ article.image | article_img_url: 'large' }}asset_img_url
Returns the CDN URL for an image in the `assets` directory of a theme.
Returns: string
string | asset_img_url| Parameters | Type | Required | Description |
|---|---|---|---|
size | string | No | The desired image size. |
{{ 'red-and-black-bramble-berries.jpg' | asset_img_url }}{{ 'red-and-black-bramble-berries.jpg' | asset_img_url: 'large' }}asset_url
Returns the CDN URL for a file in the `assets` directory of a theme.
Returns: string
string | asset_url{{ 'cart.js' | asset_url }}at_least
Limits a number to a minimum value.
Returns: number
number | at_least{{ 4 | at_least: 5 }}
{{ 4 | at_least: 3 }}at_most
Limits a number to a maximum value.
Returns: number
number | at_most{{ 6 | at_most: 5 }}
{{ 4 | at_most: 5 }}avatar
Generates HTML to render a customer's avatar, if available.
Returns: string
customer | avatarbase64_decode
Decodes a string in Base64 format.
Returns: string
string | base64_decode{{ 'b25lIHR3byB0aHJlZQ==' | base64_decode }}base64_encode
Encodes a string to Base64 format.
Returns: string
string | base64_encode{{ 'one two three' | base64_encode }}base64_url_safe_decode
Decodes a string in URL-safe Base64 format.
Returns: string
string | base64_url_safe_decode{{ 'b25lIHR3byB0aHJlZQ==' | base64_url_safe_decode }}base64_url_safe_encode
Encodes a string to URL-safe Base64 format.
Returns: string
string | base64_url_safe_encode{{ 'one two three' | base64_url_safe_encode }}brightness_difference
Calculates the perceived brightness difference between two colors.
Returns: number
string | brightness_difference: string| Parameters | Type | Required | Description |
|---|---|---|---|
color | string | Yes | A color to compare with the provided color. |
{{ '#E800B0' | brightness_difference: '#FECEE9' }}camelize
Converts a string to CamelCase.
Returns: string
string | camelize{{ 'variable-name' | camelize }}capitalize
Capitalizes the first word in a string and downcases the remaining characters.
Returns: string
string | capitalize{{ 'this sentence should start with a capitalized word.' | capitalize }}ceil
Rounds a number up to the nearest integer.
Returns: number
number | ceil{{ 1.2 | ceil }}collection_img_urlDeprecated
Returns the CDN URL for a collection's image.
Returns: string
variable | collection_img_url| Parameters | Type | Required | Description |
|---|---|---|---|
size | string | No | The desired image size. |
{{ collection.image | collection_img_url }}{{ collection.image | collection_img_url: 'large' }}color_brightness
Calculates the perceived brightness of a given color.
Returns: number
string | color_brightness{{ '#EA5AB9' | color_brightness }}color_contrast
Calculates the contrast ratio between two colors and returns the ratio's numerator. The ratio's denominator, which isn't returned, is always 1. For example, with a contrast ratio of 3.5:1, this filter returns 3.5.
Returns: number
string | color_contrast: string| Parameters | Type | Required | Description |
|---|---|---|---|
color | string | Yes | A color to compare with the provided color. |
{{ '#E800B0' | color_contrast: '#D9D8FF' }}color_darken
Darkens a given color by a specific percentage. The percentage must be between 0 and 100.
Returns: string
string | color_darken: number| Parameters | Type | Required | Description |
|---|---|---|---|
percent | number | Yes | The amount to darken the provided color by. |
{{ '#EA5AB9' | color_darken: 30 }}color_desaturate
Desaturates a given color by a specific percentage. The percentage must be between 0 and 100.
Returns: string
string | color_desaturate: number| Parameters | Type | Required | Description |
|---|---|---|---|
percent | number | Yes | The amount to desaturate the provided color by. |
{{ '#EA5AB9' | color_desaturate: 30 }}color_difference
Calculates the color difference between two colors.
Returns: number
string | color_difference: string| Parameters | Type | Required | Description |
|---|---|---|---|
color | string | Yes | A color to compare with the provided color. |
{{ '#720955' | color_difference: '#FFF3F9' }}color_extract
Extracts a specific color component from a given color.
Returns: number
string | color_extract: string| Parameters | Type | Required | Description |
|---|---|---|---|
color_component | string | Yes | The color component that you want to extract. |
{{ '#EA5AB9' | color_extract: 'red' }}color_lighten
Lightens a given color by a specific percentage. The percentage must be between 0 and 100.
Returns: string
string | color_lighten: number| Parameters | Type | Required | Description |
|---|---|---|---|
percent | number | Yes | The amount to lighten the provided color by. |
{{ '#EA5AB9' | color_lighten: 30 }}color_mix
Blends two colors together by a specific percentage factor. The percentage must be between 0 and 100.
Returns: string
string | color_mix: string, number| Parameters | Type | Required | Description |
|---|---|---|---|
color | string | Yes | A color to mix with the provided color. |
percent | number | Yes | The percentage amount to mix the colors by. |
{{ '#E800B0' | color_mix: '#00936F', 50 }}{{ 'rgba(232, 0, 176, 0.75)' | color_mix: '#00936F', 50 }}color_modify
Modifies a specific color component of a given color by a specific amount.
Returns: string
string | color_modify: string, number| Parameters | Type | Required | Description |
|---|---|---|---|
color_component | string | Yes | The color component that you want to modify. |
modification_value | number | Yes | The amount to modify the supplied color component by. |
{{ '#EA5AB9' | color_modify: 'red', 255 }}{{ '#EA5AB9' | color_modify: 'alpha', 0.85 }}color_saturate
Saturates a given color by a specific percentage. The percentage must be between 0 and 100.
Returns: string
string | color_saturate: number| Parameters | Type | Required | Description |
|---|---|---|---|
percent | number | Yes | The amount to saturate the provided color by. |
{{ '#EA5AB9' | color_saturate: 30 }}color_to_hex
Converts a CSS color string to hexadecimal format (`hex6`).
Returns: string
string | color_to_hex{{ 'rgb(234, 90, 185)' | color_to_hex }}color_to_hsl
Converts a CSS color string to `HSL` format.
Returns: string
string | color_to_hsl{{ '#EA5AB9' | color_to_hsl }}color_to_oklch
Converts a CSS color string to `OKLCH` format.
Returns: string
string | color_to_oklch{{ '#EA5AB9' | color_to_oklch }}color_to_rgb
Converts a CSS color string to `RGB` format.
Returns: string
string | color_to_rgb{{ '#EA5AB9' | color_to_rgb }}compact
Removes any `nil` items from an array.
Returns: array<untyped>
array | compact{%- assign original_prices = collection.products | map: 'compare_at_price' -%}
Original prices:
{% for price in original_prices -%}
- {{ price }}
{%- endfor %}
{%- assign compacted_original_prices = original_prices | compact -%}
Original prices - compacted:
{% for price in compacted_original_prices -%}
- {{ price }}
{%- endfor %}concat
Concatenates (combines) two arrays.
Returns: array<untyped>
array | concat: array{%- assign types_and_vendors = collection.all_types | concat: collection.all_vendors -%}
Types and vendors:
{% for item in types_and_vendors -%}
{%- if item != blank -%}
- {{ item }}
{%- endif -%}
{%- endfor %}currency_selectorDeprecated
Generates an HTML `<select>` element with an option for each currency available on the store.
Returns: string
form | currency_selector| Parameters | Type | Required | Description |
|---|---|---|---|
class | string | No | The desired `class` attribute. |
id | string | No | The desired `id` attribute. |
{% form 'currency' %}
{{ form | currency_selector }}
{% endform %}{% form 'currency' %}
{{ form | currency_selector: class: 'custom-class' }}
{% endform %}customer_login_link
Generates an HTML link to the customer login page.
Returns: string
string | customer_login_link{{ 'Log in' | customer_login_link }}customer_logout_link
Generates an HTML link to log the customer out of their account and redirect to the homepage.
Returns: string
string | customer_logout_link{{ 'Log out' | customer_logout_link }}customer_register_link
Generates an HTML link to the customer registration page.
Returns: string
string | customer_register_link{{ 'Create an account' | customer_register_link }}date
Converts a timestamp into another date format.
Returns: string
string | date: string| Parameters | Type | Required | Description |
|---|---|---|---|
format | string | No | The desired date format. |
{{ article.created_at | date: '%B %d, %Y' }}{{ 'now' | date: '%B %d, %Y' }}date
Formats a date according to a specified format string.
Returns: string
date | date: stringdefault
Sets a default value for any variable whose value is one of the following: - `empty` - `false` - `nil`
Returns: untyped
variable | default: variable| Parameters | Type | Required | Description |
|---|---|---|---|
allow_false | boolean | No | Whether to use false values instead of the default. |
{{ product.selected_variant.url | default: product.url }}{%- assign display_price = false -%}
{{ display_price | default: true, allow_false: true }}default_errors
Generates default error messages for each possible value of `form.errors`.
Returns: string
string | default_errorsdefault_pagination
Generates HTML for a set of links for paginated results. Must be applied to the `paginate` object.
Returns: string
paginate | default_pagination| Parameters | Type | Required | Description |
|---|---|---|---|
previous | string | No | The text for the previous page link. |
next | string | No | The text for the next page link. |
anchor | string | No | The anchor to add to the pagination links. |
{% paginate collection.products by 2 %}
{% for product in collection.products %}
{{- product.title }}
{% endfor %}
{{- paginate | default_pagination -}}
{% endpaginate %}{% paginate collection.products by 2 %}
{% for product in collection.products %}
{{- product.title }}
{% endfor %}
{{- paginate | default_pagination: previous: 'Previous' -}}
{% endpaginate %}divided_by
Divides a number by a given number. The `divided_by` filter produces a result of the same type as the divisor. This means if you divide by an integer, the result will be an integer, and if you divide by a float, the result will be a float.
Returns: number
number | divided_by: number{{ 4 | divided_by: 2 }}
# divisor is an integer
{{ 20 | divided_by: 7 }}
# divisor is a float
{{ 20 | divided_by: 7.0 }}downcase
Converts a string to all lowercase characters.
Returns: string
string | downcase{{ product.title | downcase }}escape
Escapes special characters in HTML, such as `<>`, `'`, and `&`, and converts characters into escape sequences. The filter doesn't effect characters within the string that don’t have a corresponding escape sequence.".
Returns: string
string | escape{{ '<p>Text to be escaped.</p>' | escape }}escape_once
Escapes a string without changing characters that have already been escaped.
Returns: string
string | escape_once# applying the escape filter to already escaped text escapes characters in HTML entities:
{{ "&lt;p&gt;Text to be escaped.&lt;/p&gt;" | escape }}
# applying the escape_once filter to already escaped text skips characters in HTML entities:
{{ "&lt;p&gt;Text to be escaped.&lt;/p&gt;" | escape_once }}
# use escape_once to escape strings where a combination of HTML entities and non-escaped characters might be present:
{{ "&lt;p&gt;Text to be escaped.&lt;/p&gt; & some additional text" | escape_once }}external_video_tag
Generates an HTML `<iframe>` tag containing the player for a given external video. The input for the `external_video_tag` filter can be either a `media` object or `external_video_url`.
Returns: string
variable | external_video_tag{% for media in product.media %}
{% if media.media_type == 'external_video' %}
{% if media.host == 'youtube' %}
{{ media | external_video_url: color: 'white' | external_video_tag }}
{% elsif media.host == 'vimeo' %}
{{ media | external_video_url: loop: '1', muted: '1' | external_video_tag }}
{% endif %}
{% endif %}
{% endfor %}{% for media in product.media %}
{% if media.media_type == 'external_video' %}
{% if media.host == 'youtube' %}
{{ media | external_video_url: color: 'white' | external_video_tag: class:'youtube-video' }}
{% endif %}
{% endif %}
{% endfor %}external_video_url
Returns the URL for a given external video. Use this filter to specify parameters for the external video player generated by the `external_video_tag` filter.
Returns: string
media | external_video_url: attribute: string{% for media in product.media %}
{% if media.media_type == 'external_video' %}
{% if media.host == 'youtube' %}
{{ media | external_video_url: color: 'white' | external_video_tag }}
{% elsif media.host == 'vimeo' %}
{{ media | external_video_url: loop: '1', muted: '1' | external_video_tag }}
{% endif %}
{% endif %}
{% endfor %}file_img_url
Returns: string
string | file_img_url| Parameters | Type | Required | Description |
|---|---|---|---|
size | string | No | The desired image size. |
{{ 'potions-header.png' | file_img_url }}{{ 'potions-header.png' | file_img_url: 'large' }}file_url
Returns: string
string | file_url| Parameters | Type | Required | Description |
|---|---|---|---|
size | string | No | The desired image size. |
{{ 'disclaimer.pdf' | file_url }}find
Returns the first item in an array with a specific property value.
Returns: untyped
array | find: string, string{% assign product = collection.products | find: 'vendor', "Polina's Potent Potions" %}
{{ product.title }}{% assign product = collection.products | find: 'vendor', "Polina's Potions" %}
{{ product.title | default: "No product found" }}find_index
Returns the index of the first item in an array with a specific property value.
Returns: number
array | find_index: string, string{% assign index = collection.products | find_index: 'vendor', "Polina's Potent Potions" %}
{{ index }}{% assign index = collection.products | find_index: 'vendor', "Polina's Potions" %}
{{ index | default: "No index found" }}first
Returns the first item in an array.
Returns: untyped
array | first{%- assign first_product = collection.products | first -%}
{{ first_product.title }}{{ collection.products.first.title }}floor
Rounds a number down to the nearest integer.
Returns: number
number | floor{{ 1.2 | floor }}font_face
Generates a CSS `@font_face` declaration to load the provided font.
Returns: string
font | font_face| Parameters | Type | Required | Description |
|---|---|---|---|
font_display | No | [string] Customize the `font_display` property of the `@font-face` declaration. |
{{ settings.type_header_font | font_face }}{{ settings.type_header_font | font_face: font_display: 'swap' }}font_modify
Modifies a specific property of a given font.
Returns: font
font | font_modify: string, string| Parameters | Type | Required | Description |
|---|---|---|---|
property | string | Yes | Font property to modify |
value | string | Yes | The new value for the associated property. |
{%- assign bold_font = settings.type_body_font | font_modify: 'weight', 'bold' -%}
h2 {
font-weight: {{ bold_font.weight }};
}{%- assign bold_font = settings.type_body_font | font_modify: 'weight', 'bold' -%}
{%- assign italic_font = settings.type_body_font | font_modify: 'style', 'italic' -%}
{%- assign heavy_font = settings.type_body_font | font_modify: 'weight', '900' | default: bold_font -%}
{%- assign oblique_font = settings.type_body_font | font_modify: 'style', 'oblique' | default: italic_font -%}
h2 {
font-style: {{ heavy_font.weight }};
}
.italic {
{% if oblique_font -%}
font-style: {{ oblique_font.style }};
{%- else -%}
font-style: {{ italic_font.style }};
{%- endif %}
}font_url
Returns the CDN URL for the provided font in `woff2` format.
Returns: string
font | font_url| Parameters | Type | Required | Description |
|---|---|---|---|
font_type | string | No | Choose to return the URL for the font in `woff` format, instead of `woff2`. |
{{ settings.type_header_font | font_url }}{{ settings.type_header_font | font_url: 'woff' }}format_address
Generates an HTML address display, with each address component ordered according to the address's locale.
Returns: string
address | format_address{{ shop.address | format_address }}{{ customer.default_address | format_address }}handleize
Converts a string into a handle.
Alias: handle
Returns: string
string | handleize{{ product.title | handleize }}
{{ product.title | handle }}has
Tests if any item in an array has a specific property value.
Returns: boolean
array | has: string, string{% assign has_potent_potions = collection.products | has: 'vendor', "Polina's Potent Potions" %}
{{ has_potent_potions }}{% assign has_potent_potions = collection.products | has: 'vendor', "Polina's Potions" %}
{{ has_potent_potions }}hex_to_rgbaDeprecated
Converts a CSS color string from hexadecimal format to `RGBA` format. Shorthand hexadecimal formatting (`hex3`) is also accepted.
Returns: string
string | hex_to_rgba| Parameters | Type | Required | Description |
|---|---|---|---|
alpha | number | No | The desired alpha value. |
{{ '#EA5AB9' | hex_to_rgba }}{{ '#EA5AB9' | hex_to_rgba: 0.5 }}highlight
Wraps all instances of a specific string, within a given string, with an HTML `<strong>` tag with a `class` attribute of `highlight`.
Returns: string
string | highlight: string| Parameters | Type | Required | Description |
|---|---|---|---|
highlighted_term | string | Yes | The string that you want to highlight. |
{% for item in search.results %}
{% if item.object_type == 'product' %}
{{ item.description | highlight: search.terms }}
{% else %}
{{ item.content | highlight: search.terms }}
{% endif %}
{% endfor %}highlight_active_tag
Wraps a given tag within the `collection` object in an HTML `<span>` tag, with a `class` attribute of `active`, if the tag is currently active. Only applies to collection tags.
Returns: string
string | highlight_active_tag{% for tag in collection.all_tags %}
{{- tag | highlight_active_tag | link_to_tag: tag }}
{% endfor %}hmac_sha1
Converts a string into an SHA-1 hash using a hash message authentication code (HMAC).
Returns: string
string | hmac_sha1: string{%- assign secret_potion = 'Polyjuice' | hmac_sha1: 'Polina' -%}
My secret potion: {{ secret_potion }}hmac_sha256
Converts a string into an SHA-256 hash using a hash message authentication code (HMAC).
Returns: string
string | hmac_sha256: string{%- assign secret_potion = 'Polyjuice' | hmac_sha256: 'Polina' -%}
My secret potion: {{ secret_potion }}image_tag
Generates an HTML `<img>` tag for a given `image_url`.
Returns: string
string | image_tag| Parameters | Type | Required | Description |
|---|---|---|---|
width | number | No | The width of the image. |
height | number | No | The height of the image. |
sizes | number | No | The source sizes for responsiveness. |
widths | number | No | The widths to associate with custom `srcset` values. |
srcset | number | No | The `srcset` for responsiveness. |
preload | boolean | No | Whether the resource should be preloaded. |
alt | number | No | The image's alt text. |
{{ product | image_url: width: 200 | image_tag }}{{ images['potions-header.png'] | image_url: width: 300 | image_tag }}image_url
Returns the CDN URL for an image.
Returns: string
variable | image_url: width: number, height: number| Parameters | Type | Required | Description |
|---|---|---|---|
crop | string | No | How the image should be cropped to match the desired dimensions. |
format | string | No | The file format for the image. |
pad_color | string | No | The padding color, if the provided image is smaller than the requested dimensions. |
width | number | Yes | The desired image width, in pixels. |
height | number | Yes | The desired image height, in pixels. |
{{ product | image_url: width: 450 }}{{ product | image_url: width: 450 }}img_tagDeprecated
Generates an HTML `<img>` tag for a given image URL.
Returns: string
string | img_tag| Parameters | Type | Required | Description |
|---|---|---|---|
alt | string | No | The image's alt text. |
class | string | No | The desired `class` attribute. |
size | string | No | The desired image size. |
{{ product | img_tag }}{{ product | img_tag: 'image alt text', '', '450x450' }}img_urlDeprecated
Returns the CDN URL for an image.
Returns: string
variable | img_url| Parameters | Type | Required | Description |
|---|---|---|---|
size | string | No | The desired image size. |
crop | string | No | The part of the image to show if the specified image has an aspect ratio that differs from the original. |
scale | number | No | The desired pixel density. |
format | string | No | The desired image format. |
{{ product | img_url }}{{ product | img_url: '480x' }}
{{ product | img_url: 'x480' }}
{{ product | img_url: '480x480' }}
{{ product | img_url: 'large' }}inline_asset_content
Outputs the content of an asset inline in the template. The asset must be either a SVG, JS, or CSS file.
Returns: string
asset_name | inline_asset_content{{ 'icon.svg' | inline_asset_content }}item_count_for_variant
Returns the total item count for a specified variant in the `cart` object.
Returns: number
cart | item_count_for_variant: {variant_id}{{ cart | item_count_for_variant: 39888235757633 }}join
Combines all of the items in an array into a single string, separated by a space.
Returns: string
array | join{{ collection.all_tags | join }}{{ collection.all_tags | join: ', ' }}json
Converts a string, or object, into JSON format.
Returns: string
variable | json{{ product | json }}last
Returns the last item in an array.
Returns: untyped
array | last{%- assign last_product = collection.products | last -%}
{{ last_product.title }}{{ collection.products.last.title }}line_items_for
Returns the subset of `cart` line items that include a specified product or variant.
Returns: array<line_item>
cart | line_items_for: object{% assign product = all_products['bloodroot-whole'] %}
{% assign line_items = cart | line_items_for: product %}
Total cart quantity for product: {{ line_items | sum: 'quantity' }}{% assign product = all_products['bloodroot-whole'] %}
{% assign variant = product.variants.first %}
{% assign line_items = cart | line_items_for: variant %}
Total cart quantity for variant: {{ line_items | sum: 'quantity' }}link_to
Generates an HTML `<a>` tag.
Returns: string
string | link_to: string| Parameters | Type | Required | Description |
|---|---|---|---|
url | string | Yes | The URL to link to. |
link_to_add_tag
Generates an HTML `<a>` tag with an `href` attribute linking to the current blog or collection, filtered to show only articles or products that have a given tag, as well as any currently active tags.
Returns: string
string | link_to_add_tag{% for tag in collection.all_tags %}
{%- if current_tags contains tag -%}
{{ tag }}
{%- else -%}
{{ tag | link_to_add_tag: tag }}
{%- endif -%}
{% endfor %}link_to_remove_tag
Generates an HTML `<a>` tag with an `href` attribute linking to the current blog or collection, filtered to show only articles or products that have any currently active tags, except the provided tag.
Returns: string
string | link_to_remove_tag{% for tag in collection.all_tags %}
{%- if current_tags contains tag -%}
{{ tag | link_to_remove_tag: tag }}
{%- else -%}
{{ tag | link_to_add_tag: tag }}
{%- endif -%}
{% endfor %}link_to_tag
Generates an HTML `<a>` tag with an `href` attribute linking to the current blog or collection, filtered to show only articles or products that have a given tag.
Returns: string
string | link_to_tag{% for tag in collection.all_tags %}
{{- tag | link_to_tag: tag }}
{% endfor %}link_to_type
Generates an HTML `<a>` tag with an `href` attribute linking to a collection page that lists all products of the given product type.
Returns: string
string | link_to_type| Parameters | Type | Required | Description |
|---|---|---|---|
HTML | No | attribute [string] You can specify the value of supported HTML attributes. |
{{ 'Health' | link_to_type }}{{ 'Health' | link_to_type: class: 'link-class' }}link_to_vendor
Generates an HTML `<a>` tag with an `href` attribute linking to a collection page that lists all products of a given product vendor.
Returns: string
string | link_to_vendor| Parameters | Type | Required | Description |
|---|---|---|---|
HTML | No | attribute [string] HTML attributes for the link, passed as `attribute: value`. |
{{ "Polina's Potent Potions" | link_to_vendor }}{{ "Polina's Potent Potions" | link_to_vendor: class: 'link-class' }}lstrip
Strips all whitespace from the left of a string.
Returns: string
string | lstrip{%- assign text = ' Some potions create whitespace. ' -%}
"{{ text }}"
"{{ text | lstrip }}"map
Creates an array of values from a specific property of the items in an array.
Returns: array<untyped>
array | map: string{%- assign product_titles = collection.products | map: 'title' -%}
{{ product_titles | join: ', ' }}md5
Converts a string into an MD5 hash. MD5 is not considered safe anymore. Please use 'blake3' instead for better security and performance.
Returns: string
string | md5{{ '' | md5 }}media_tag
Generates an appropriate HTML tag for a given media object.
Returns: string
media | media_tag| Parameters | Type | Required | Description |
|---|---|---|---|
image_size | string | No | The dimensions of the media's poster image. |
{% for media in product.media %}
{{- media | media_tag }}
{% endfor %}{% for media in product.media %}
{{- media | media_tag: image_size: '400x' }}
{% endfor %}metafield_tag
Generates an HTML element to host the data from a `metafield` object. The type of element that's generated differs depending on the type of metafield.
Returns: string
metafield | metafield_tag| Parameters | Type | Required | Description |
|---|---|---|---|
field | string | No | Specifies which field should be used. Only applicable to `list.metaobject_reference` and `metaobject_reference` types. |
list_format | string | No | The desired list format. Accepts `unordered` or `ordered`. Default: `unordered`. |
<!-- boolean -->
{{ product.metafields.information.seasonal | metafield_tag }}
<!-- collection_reference -->
{{ product.metafields.information.related_collection | metafield_tag }}
<!-- color -->
{{ product.metafields.details.potion_color | metafield_tag }}
<!-- date -->
{{ product.metafields.information.expiry | metafield_tag }}
<!-- date_time -->
{{ product.metafields.information.brew_date | metafield_tag }}
<!-- json -->
{{ product.metafields.information.burn_temperature | metafield_tag }}
<!-- money -->
{{ product.metafields.details.price_per_ml | metafield_tag }}
<!-- multi_line_text_field -->
{{ product.metafields.information.shipping | metafield_tag }}
<!-- number_decimal -->
{{ product.metafields.information.salinity | metafield_tag }}
<!-- number_integer -->
{{ product.metafields.information.doses_per_day | metafield_tag }}
<!-- page_reference -->
{{ product.metafields.information.dosage | metafield_tag }}
<!-- product_reference -->
{{ product.metafields.information.related_product | metafield_tag }}
<!-- rating -->
{{ product.metafields.details.rating | metafield_tag }}
<!-- single_line_text_field -->
{{ product.metafields.information.directions | metafield_tag }}
<!-- url -->
{{ product.metafields.information.health | metafield_tag }}
<!-- variant_reference -->
{{ product.metafields.information.best_seller | metafield_tag }}
<!-- rich_text_field -->
{{ product.metafields.information.rich_description | metafield_tag }}{{ product.metafields.details.scale_width | metafield_tag }}metafield_text
Generates a text version of the data from a `metafield` object.
Returns: string
metafield | metafield_text| Parameters | Type | Required | Description |
|---|---|---|---|
field | string | No | Specifies which field should be used. Only applicable to types `list.metaobject_reference` and `metaobject_reference`. |
{{ product.metafields.information.dosage | metafield_text }}{{ product.metafields.information.ingredients | metafield_text: field: 'name' }}minus
Subtracts a given number from another number.
Returns: number
number | minus: number{{ 4 | minus: 2 }}model_viewer_tag
Generates a Google model viewer component for a given 3D model.
Returns: string
media | model_viewer_tag| Parameters | Type | Required | Description |
|---|---|---|---|
image_size | string | No | The dimensions of the model viewer's poster image. |
{% for media in product.media %}
{% if media.media_type == 'model' %}
{{ media | model_viewer_tag }}
{% endif %}
{% endfor %}{% for media in product.media %}
{% if media.media_type == 'model' %}
{{ media | model_viewer_tag: interaction-policy: 'allow-when-focused' }}
{% endif %}
{% endfor %}modulo
Returns the remainder of dividing a number by a given number.
Returns: number
number | modulo: number{{ 12 | modulo: 5 }}money
Formats a given price based on the store's **HTML without currency** setting.
Returns: string
number | money{{ product.price | money }}money_amount
Formats a given price as a plain decimal string, without currency symbols, thousand separators, or locale formatting.
Returns: string
number | money_amount{{ product.price | money_amount }}money_with_currency
Formats a given price based on the store's **HTML with currency** setting.
Returns: string
number | money_with_currency{{ product.price | money_with_currency }}money_without_currency
Formats a given price based on the store's **HTML without currency** setting, without the currency symbol.
Returns: string
number | money_without_currency{{ product.price | money_without_currency }}money_without_trailing_zeros
Formats a given price based on the store's **HTML without currency** setting, excluding the decimal separator (either `.` or `,`) and trailing zeros. If the price has a non-zero decimal value, then the output is the same as the `money` filter.
Returns: string
number | money_without_trailing_zeros{{ product.price | money_without_trailing_zeros }}newline_to_br
Converts newlines (`\n`) in a string to HTML line breaks (`<br>`).
Returns: string
string | newline_to_br{{ product.description | newline_to_br }}placeholder_svg_tag
Generates an HTML `<svg>` tag for a given placeholder name.
Returns: string
string | placeholder_svg_tag| Parameters | Type | Required | Description |
|---|---|---|---|
class | string | No | The desired `class` attribute. |
{{ 'collection-1' | placeholder_svg_tag }}{{ 'collection-1' | placeholder_svg_tag: 'custom-class' }}pluralize
Outputs the singular or plural version of a string based on a given number.
Returns: string
number | pluralize: string, stringCart item count: {{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }}plus
Adds two numbers.
Returns: number
number | plus: number{{ 2 | plus: 2 }}preload_tag
Returns: string
string | preload_tag: as: string| Parameters | Type | Required | Description |
|---|---|---|---|
as | string | Yes | The type of element or resource to preload. |
{{ 'cart.js' | asset_url | preload_tag: as: 'script' }}{{ 'cart.js' | asset_url | preload_tag: as: 'script', type: 'text/javascript' }}prepend
Adds a given string to the beginning of a string.
Returns: string
string | prepend: string{%- assign origin = request.origin -%}
{{ product.url | prepend: origin }}product_img_urlDeprecated
Returns the CDN URL for a product image.
Returns: string
variable | product_img_url| Parameters | Type | Required | Description |
|---|---|---|---|
size | string | No | The desired image size. |
{{ product.featured_image | product_img_url }}{{ product.images[0] | product_img_url: 'large' }}reject
Filters an array to exclude items with a specific property value.
Returns: array<untyped>
array | reject: string, string{% assign polina_products = collection.products | reject: 'vendor', "Polina's Potent Potions" %}
Products from other vendors than Polina's Potent Potions:
{% for product in polina_products -%}
- {{ product.title }}
{%- endfor %}remove
Removes any instance of a substring inside a string.
Returns: string
string | remove: string{{ "I can't do it!" | remove: "'t" }}remove_first
Removes the first instance of a substring inside a string.
Returns: string
string | remove_first: string{{ "I hate it when I accidentally spill my duplication potion accidentally!" | remove_first: ' accidentally' }}remove_last
Removes the last instance of a substring inside a string.
Returns: string
string | remove_last: string{{ "I hate it when I accidentally spill my duplication potion accidentally!" | remove_last: ' accidentally' }}replace
Replaces any instance of a substring inside a string with a given string.
Returns: string
string | replace: string, string{{ product.handle | replace: '-', ' ' }}replace_first
Replaces the first instance of a substring inside a string with a given string.
Returns: string
string | replace_first: string, string{{ product.handle | replace_first: '-', ' ' }}replace_last
Replaces the last instance of a substring inside a string with a given string.
Returns: string
string | replace_last: string, string{{ product.handle | replace_last: '-', ' ' }}reverse
Reverses the order of the items in an array.
Returns: array<untyped>
array | reverseOriginal order:
{{ collection.products | map: 'title' | join: ', ' }}
Reverse order:
{{ collection.products | reverse | map: 'title' | join: ', ' }}{{ collection.title | split: '' | reverse | join: '' }}round
Rounds a number to the nearest integer.
Returns: number
number | round{{ 2.7 | round }}
{{ 1.3 | round }}{{ 3.14159 | round: 2 }}rstrip
Strips all whitespace from the right of a string.
Returns: string
string | rstrip{%- assign text = ' Some potions create whitespace. ' -%}
"{{ text }}"
"{{ text | rstrip }}"script_tag
Generates an HTML `<script>` tag for a given resource URL. The tag has a `type` attribute of `text/javascript`.
Returns: string
string | script_tag{{ 'cart.js' | asset_url | script_tag }}sha1
Converts a string into an SHA-1 hash. SHA-1 is not considered safe anymore. Please use 'blake3' instead for better security and performance.
Returns: string
string | sha1: string{%- assign secret_potion = 'Polyjuice' | sha1 -%}
My secret potion: {{ secret_potion }}sha256
Converts a string into an SHA-256 hash. Please use 'blake3' instead for better security and performance.
Returns: string
string | sha256: string{%- assign secret_potion = 'Polyjuice' | sha256 -%}
My secret potion: {{ secret_potion }}size
Returns the size of a string or array.
Returns: number
variable | size{{ collection.title | size }}
{{ collection.products | size }}{% if collection.products.size >= 10 %}
There are 10 or more products in this collection.
{% else %}
There are less than 10 products in this collection.
{% endif %}slice
Returns a substring or series of array items, starting at a given 0-based index.
Returns: string
string | slice{{ collection.title | slice: 0 }}
{{ collection.title | slice: 0, 5 }}
{{ collection.all_tags | slice: 1, 2 | join: ', ' }}{{ collection.title | slice: -3, 3 }}sort
Sorts the items in an array in case-sensitive alphabetical, or numerical, order.
Returns: array<untyped>
array | sort{% assign tags = collection.all_tags | sort %}
{% for tag in tags -%}
{{ tag }}
{%- endfor %}{% assign products = collection.products | sort: 'price' %}
{% for product in products -%}
{{ product.title }}
{%- endfor %}sort_by
Generates a collection URL with the provided `sort_by` parameter appended. This filter must be applied to the object property `collection.url`.
Returns: string
string | sort_by: string{{ collection.url | sort_by: 'best-selling' }}sort_natural
Sorts the items in an array in case-insensitive alphabetical order.
Returns: array<untyped>
array | sort_natural{% assign tags = collection.all_tags | sort_natural %}
{% for tag in tags -%}
{{ tag }}
{%- endfor %}{% assign products = collection.products | sort_natural: 'title' %}
{% for product in products -%}
{{ product.title }}
{%- endfor %}split
Splits a string into an array of substrings based on a given separator.
Returns: array<string>
string | split: string{%- assign title_words = product.handle | split: '-' -%}
{% for word in title_words -%}
{{ word }}
{%- endfor %}strip
Strips all whitespace from the left and right of a string.
Returns: string
string | strip{%- assign text = ' Some potions create whitespace. ' -%}
"{{ text }}"
"{{ text | strip }}"strip_html
Strips all HTML tags from a string.
Returns: string
string | strip_html<!-- With HTML -->
{{ product.description }}
<!-- HTML stripped -->
{{ product.description | strip_html }}strip_newlines
Strips all newline characters (line breaks) from a string.
Returns: string
string | strip_newlines<!-- With newlines -->
{{ product.description }}
<!-- Newlines stripped -->
{{ product.description | strip_newlines }}structured_data
Converts an object into a schema.org structured data format.
Returns: string
variable | structured_data<script type="application/ld+json">
{{ product | structured_data }}
</script>stylesheet_tag
Generates an HTML `<link>` tag for a given resource URL. The tag has the following parameters: | Attribute | Value | | --- | --- | | `rel` | `stylesheet` | | `type` | `text/css` | | `media` | `all` |
Returns: string
string | stylesheet_tag| Parameters | Type | Required | Description |
|---|---|---|---|
media | string | No | The type of media that the resource applies to. |
preload | boolean | No | Whether the resource should be preloaded. |
{{ 'base.css' | asset_url | stylesheet_tag }}stylesheet_url | stylesheet_tag: preload: booleansum
Returns the sum of all elements in an array.
Returns: number
array | sum{% assign fibonacci = '0, 1, 1, 2, 3, 5' | split: ', ' %}
{{ fibonacci | sum }}Total quantity of all items in cart:
{{ cart.items | sum: 'quantity' }}
Subtotal price for all items in cart:
{{ cart.items | sum: 'final_line_price' | money }}time_tag
Converts a timestamp into an HTML `<time>` tag.
Returns: string
string | time_tag: string| Parameters | Type | Required | Description |
|---|---|---|---|
format | string | No | The desired date format. |
datetime | string | No | The format for the datetime attribute of the time element. |
{{ article.created_at | time_tag: '%B %d, %Y' }}{{ article.created_at | time_tag: format: 'abbreviated_date' }}times
Multiplies a number by a given number.
Returns: number
number | times: number{{ 2 | times: 2 }}translate
Returns a string of translated text for a given translation key from a locale file.
Alias: t
Returns: string
string | ttruncate
Truncates a string down to a given number of characters.
Returns: string
string | truncate: number{{ article.title | truncate: 15 }}{{ article.title | truncate: 15, '--' }}
{{ article.title | truncate: 15, '' }}truncatewords
Truncates a string down to a given number of words.
Returns: string
string | truncatewords: number{{ article.content | strip_html | truncatewords: 15 }}{{ article.content | strip_html | truncatewords: 15, '--' }}
{{ article.content | strip_html | truncatewords: 15, '' }}uniq
Removes any duplicate items in an array.
Returns: array<untyped>
array | uniq{% assign potion_array = 'invisibility, health, love, health, invisibility' | split: ', ' %}
{{ potion_array | uniq | join: ', ' }}unit_price_with_measurement
Formats a given unit price and measurement based on the store's **HTML without currency** setting.
Returns: string
number | unit_price_with_measurement: unit_price_measurement{%- assign variant = product.variants.first -%}
{{ variant.unit_price | unit_price_with_measurement: variant.unit_price_measurement }}{%- assign variant = product.variants.first -%}
{{ variant.unit_price | money_with_currency | unit_price_with_measurement: variant.unit_price_measurement }}upcase
Converts a string to all uppercase characters.
Returns: string
string | upcase{{ product.title | upcase }}url_decode
Decodes any percent-encoded characters in a string.
Returns: string
string | url_decode{{ 'test%40test.com' | url_decode }}url_encode
Converts any URL-unsafe characters in a string to the percent-encoded equivalent.
Returns: string
string | url_encode{{ '[email protected]' | url_encode }}url_escape
Escapes any URL-unsafe characters in a string.
Returns: string
string | url_escape{{ '<p>Health & Love potions</p>' | url_escape }}url_for_type
Generates a URL for a collection page that lists all products of the given product type.
Returns: string
string | url_for_type{{ 'health' | url_for_type }}url_for_vendor
Generates a URL for a collection page that lists all products from the given product vendor.
Returns: string
string | url_for_vendor{{ "Polina's Potent Potions" | url_for_vendor }}url_param_escape
Escapes any characters in a string that are unsafe for URL parameters.
Returns: string
string | url_param_escape{{ '<p>Health & Love potions</p>' | url_param_escape }}video_tag
Generates an HTML `<video>` tag for a given video.
Returns: string
media | video_tag| Parameters | Type | Required | Description |
|---|---|---|---|
image_size | string | No | The dimensions of the video's poster image. |
{% for media in product.media %}
{% if media.media_type == 'video' %}
{{ media | video_tag }}
{% endif %}
{% endfor %}{% for media in product.media %}
{% if media.media_type == 'video' %}
{{ media | video_tag: image_size: '400x' }}
{% endif %}
{% endfor %}weight_with_unit
Returns: string
number | weight_with_unit| Parameters | Type | Required | Description |
|---|---|---|---|
weight_unit | string | No | The weight unit to use in place of the default weight unit. |
{%- assign variant = product.variants.first -%}
{{ variant.weight | weight_with_unit }}{%- assign variant = product.variants.first -%}
{{ variant.weight | weight_with_unit: variant.weight_unit }}where
Filters an array to include only items with a specific property value.
Returns: array<untyped>
array | where: string, string{% assign polina_products = collection.products | where: 'vendor', "Polina's Potent Potions" %}
Products from Polina's Potent Potions:
{% for product in polina_products -%}
- {{ product.title }}
{%- endfor %}{% assign available_products = collection.products | where: 'available' %}
Available products:
{% for product in available_products -%}
- {{ product.title }}
{%- endfor %}within
Generates a product URL within the context of the provided collection.
Returns: string
string | within: collection{%- assign collection_product = collection.products.first -%}
{{ collection_product.url | within: collection }}