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

Syntax
number | abs
Example
{{ -3 | abs }}

append

Adds a given string to the end of a string.

Returns: string

Syntax
string | append: string
Example
{%-  assign path = product.url -%}

{{ request.origin | append: path }}

article_img_urlDeprecated

Returns the CDN URL for an article's image.

Returns: string

Syntax
variable | article_img_url
ParametersTypeRequiredDescription
sizestringNoThe desired image size.
Example
{{ article.image | article_img_url }}
Example — size
{{ 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

Syntax
string | asset_img_url
ParametersTypeRequiredDescription
sizestringNoThe desired image size.
Example
{{ 'red-and-black-bramble-berries.jpg' | asset_img_url }}
Example — size
{{ '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

Syntax
string | asset_url
Example
{{ 'cart.js' | asset_url }}

at_least

Limits a number to a minimum value.

Returns: number

Syntax
number | at_least
Example
{{ 4 | at_least: 5 }}
{{ 4 | at_least: 3 }}

at_most

Limits a number to a maximum value.

Returns: number

Syntax
number | at_most
Example
{{ 6 | at_most: 5 }}
{{ 4 | at_most: 5 }}

avatar

Generates HTML to render a customer's avatar, if available.

Returns: string

Syntax
customer | avatar

base64_decode

Decodes a string in Base64 format.

Returns: string

Syntax
string | base64_decode
Example
{{ 'b25lIHR3byB0aHJlZQ==' | base64_decode }}

base64_encode

Encodes a string to Base64 format.

Returns: string

Syntax
string | base64_encode
Example
{{ 'one two three' | base64_encode }}

base64_url_safe_decode

Decodes a string in URL-safe Base64 format.

Returns: string

Syntax
string | base64_url_safe_decode
Example
{{ 'b25lIHR3byB0aHJlZQ==' | base64_url_safe_decode }}

base64_url_safe_encode

Encodes a string to URL-safe Base64 format.

Returns: string

Syntax
string | base64_url_safe_encode
Example
{{ 'one two three' | base64_url_safe_encode }}

brightness_difference

Calculates the perceived brightness difference between two colors.

Returns: number

Syntax
string | brightness_difference: string
ParametersTypeRequiredDescription
colorstringYesA color to compare with the provided color.
Example
{{ '#E800B0' | brightness_difference: '#FECEE9' }}

camelize

Converts a string to CamelCase.

Returns: string

Syntax
string | camelize
Example
{{ 'variable-name' | camelize }}

capitalize

Capitalizes the first word in a string and downcases the remaining characters.

Returns: string

Syntax
string | capitalize
Example
{{ 'this sentence should start with a capitalized word.' | capitalize }}

ceil

Rounds a number up to the nearest integer.

Returns: number

Syntax
number | ceil
Example
{{ 1.2 | ceil }}

collection_img_urlDeprecated

Returns the CDN URL for a collection's image.

Returns: string

Syntax
variable | collection_img_url
ParametersTypeRequiredDescription
sizestringNoThe desired image size.
Example
{{ collection.image | collection_img_url }}
Example — The size parameter
{{ collection.image | collection_img_url: 'large' }}

color_brightness

Calculates the perceived brightness of a given color.

Returns: number

Syntax
string | color_brightness
Example
{{ '#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

Syntax
string | color_contrast: string
ParametersTypeRequiredDescription
colorstringYesA color to compare with the provided color.
Example
{{ '#E800B0' | color_contrast: '#D9D8FF' }}

color_darken

Darkens a given color by a specific percentage. The percentage must be between 0 and 100.

Returns: string

Syntax
string | color_darken: number
ParametersTypeRequiredDescription
percentnumberYesThe amount to darken the provided color by.
Example
{{ '#EA5AB9' | color_darken: 30 }}

color_desaturate

Desaturates a given color by a specific percentage. The percentage must be between 0 and 100.

Returns: string

Syntax
string | color_desaturate: number
ParametersTypeRequiredDescription
percentnumberYesThe amount to desaturate the provided color by.
Example
{{ '#EA5AB9' | color_desaturate: 30 }}

color_difference

Calculates the color difference between two colors.

Returns: number

Syntax
string | color_difference: string
ParametersTypeRequiredDescription
colorstringYesA color to compare with the provided color.
Example
{{ '#720955' | color_difference: '#FFF3F9' }}

color_extract

Extracts a specific color component from a given color.

Returns: number

Syntax
string | color_extract: string
ParametersTypeRequiredDescription
color_componentstringYesThe color component that you want to extract.
Example
{{ '#EA5AB9' | color_extract: 'red' }}

color_lighten

Lightens a given color by a specific percentage. The percentage must be between 0 and 100.

Returns: string

Syntax
string | color_lighten: number
ParametersTypeRequiredDescription
percentnumberYesThe amount to lighten the provided color by.
Example
{{ '#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

Syntax
string | color_mix: string, number
ParametersTypeRequiredDescription
colorstringYesA color to mix with the provided color.
percentnumberYesThe percentage amount to mix the colors by.
Example
{{ '#E800B0' | color_mix: '#00936F', 50 }}
Example
{{ '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

Syntax
string | color_modify: string, number
ParametersTypeRequiredDescription
color_componentstringYesThe color component that you want to modify.
modification_valuenumberYesThe amount to modify the supplied color component by.
Example
{{ '#EA5AB9' | color_modify: 'red', 255 }}
Example
{{ '#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

Syntax
string | color_saturate: number
ParametersTypeRequiredDescription
percentnumberYesThe amount to saturate the provided color by.
Example
{{ '#EA5AB9' | color_saturate: 30 }}

color_to_hex

Converts a CSS color string to hexadecimal format (`hex6`).

Returns: string

Syntax
string | color_to_hex
Example
{{ 'rgb(234, 90, 185)' | color_to_hex }}

color_to_hsl

Converts a CSS color string to `HSL` format.

Returns: string

Syntax
string | color_to_hsl
Example
{{ '#EA5AB9' | color_to_hsl }}

color_to_oklch

Converts a CSS color string to `OKLCH` format.

Returns: string

Syntax
string | color_to_oklch
Example
{{ '#EA5AB9' | color_to_oklch }}

color_to_rgb

Converts a CSS color string to `RGB` format.

Returns: string

Syntax
string | color_to_rgb
Example
{{ '#EA5AB9' | color_to_rgb }}

compact

Removes any `nil` items from an array.

Returns: array<untyped>

Syntax
array | compact
Example
{%- 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>

Syntax
array | concat: array
Example
{%- 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

Syntax
form | currency_selector
ParametersTypeRequiredDescription
classstringNoThe desired `class` attribute.
idstringNoThe desired `id` attribute.
Example
{% form 'currency' %}
  {{ form | currency_selector }}
{% endform %}
Example — class
{% form 'currency' %}
  {{ form | currency_selector: class: 'custom-class' }}
{% endform %}

date

Converts a timestamp into another date format.

Returns: string

Syntax
string | date: string
ParametersTypeRequiredDescription
formatstringNoThe desired date format.
Example
{{ article.created_at | date: '%B %d, %Y' }}
Example — The current date
{{ 'now' | date: '%B %d, %Y' }}

date

Formats a date according to a specified format string.

Returns: string

Syntax
date | date: string

default

Sets a default value for any variable whose value is one of the following: - `empty` - `false` - `nil`

Returns: untyped

Syntax
variable | default: variable
ParametersTypeRequiredDescription
allow_falsebooleanNoWhether to use false values instead of the default.
Example
{{ product.selected_variant.url | default: product.url }}
Example — allow_false
{%- 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

Syntax
string | default_errors

default_pagination

Generates HTML for a set of links for paginated results. Must be applied to the `paginate` object.

Returns: string

Syntax
paginate | default_pagination
ParametersTypeRequiredDescription
previousstringNoThe text for the previous page link.
nextstringNoThe text for the next page link.
anchorstringNoThe anchor to add to the pagination links.
Example
{% paginate collection.products by 2 %}
  {% for product in collection.products %}
    {{- product.title }}
  {% endfor %}

  {{- paginate | default_pagination -}}
{% endpaginate %}
Example — previous
{% 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

Syntax
number | divided_by: number
Example
{{ 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

Syntax
string | downcase
Example
{{ 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

Syntax
string | escape
Example
{{ '&lt;p&gt;Text to be escaped.&lt;/p&gt;' | escape }}

escape_once

Escapes a string without changing characters that have already been escaped.

Returns: string

Syntax
string | escape_once
Example
# applying the escape filter to already escaped text escapes characters in HTML entities:

{{ "&amp;lt;p&amp;gt;Text to be escaped.&amp;lt;/p&amp;gt;" | escape }}

# applying the escape_once filter to already escaped text skips characters in HTML entities:

{{ "&amp;lt;p&amp;gt;Text to be escaped.&amp;lt;/p&amp;gt;" | escape_once }}

# use escape_once to escape strings where a combination of HTML entities and non-escaped characters might be present:

{{ "&amp;lt;p&amp;gt;Text to be escaped.&amp;lt;/p&amp;gt; &amp; 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

Syntax
variable | external_video_tag
Example
{% 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 %}
Example — HTML attributes
{% 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

Syntax
media | external_video_url: attribute: string
Example
{% 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

Syntax
string | file_img_url
ParametersTypeRequiredDescription
sizestringNoThe desired image size.
Example
{{ 'potions-header.png' | file_img_url }}
Example — The size parameter
{{ 'potions-header.png' | file_img_url: 'large' }}

file_url

Returns: string

Syntax
string | file_url
ParametersTypeRequiredDescription
sizestringNoThe desired image size.
Example
{{ 'disclaimer.pdf' | file_url }}

find

Returns the first item in an array with a specific property value.

Returns: untyped

Syntax
array | find: string, string
Example
{% assign product = collection.products | find: 'vendor', "Polina's Potent Potions" %}

{{ product.title }}
Example — Returns `nil` when no items match the specified property value.
{% 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

Syntax
array | find_index: string, string
Example
{% assign index = collection.products | find_index: 'vendor', "Polina's Potent Potions" %}

{{ index }}
Example — Returns `nil` when no items match the specified property value.
{% 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

Syntax
array | first
Example
{%- assign first_product = collection.products | first -%}

{{ first_product.title }}
Example — Dot notation
{{ collection.products.first.title }}

floor

Rounds a number down to the nearest integer.

Returns: number

Syntax
number | floor
Example
{{ 1.2 | floor }}

font_face

Generates a CSS `@font_face` declaration to load the provided font.

Returns: string

Syntax
font | font_face
ParametersTypeRequiredDescription
font_displayNo[string] Customize the `font_display` property of the `@font-face` declaration.
Example
{{ settings.type_header_font | font_face }}
Example — font_display
{{ settings.type_header_font | font_face: font_display: 'swap' }}

font_modify

Modifies a specific property of a given font.

Returns: font

Syntax
font | font_modify: string, string
ParametersTypeRequiredDescription
propertystringYesFont property to modify
valuestringYesThe new value for the associated property.
Example
{%- assign bold_font = settings.type_body_font | font_modify: 'weight', 'bold' -%}

h2 {
  font-weight: {{ bold_font.weight }};
}
Example — Non-existent font variants
{%- 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

Syntax
font | font_url
ParametersTypeRequiredDescription
font_typestringNoChoose to return the URL for the font in `woff` format, instead of `woff2`.
Example
{{ settings.type_header_font | font_url }}
Example — woff format
{{ 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

Syntax
address | format_address
Example
{{ shop.address | format_address }}
Example
{{ customer.default_address | format_address }}

handleize

Converts a string into a handle.

Alias: handle

Returns: string

Syntax
string | handleize
Example
{{ product.title | handleize }}
{{ product.title | handle }}

has

Tests if any item in an array has a specific property value.

Returns: boolean

Syntax
array | has: string, string
Example
{% assign has_potent_potions = collection.products | has: 'vendor', "Polina's Potent Potions" %}

{{ has_potent_potions }}
Example — Returns `false` when no items match the specified property value.
{% 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

Syntax
string | hex_to_rgba
ParametersTypeRequiredDescription
alphanumberNoThe desired alpha value.
Example
{{ '#EA5AB9' | hex_to_rgba }}
Example — alpha
{{ '#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

Syntax
string | highlight: string
ParametersTypeRequiredDescription
highlighted_termstringYesThe string that you want to highlight.
Example
{% 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

Syntax
string | highlight_active_tag
Example
{% 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

Syntax
string | hmac_sha1: string
Example
{%- 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

Syntax
string | hmac_sha256: string
Example
{%- 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

Syntax
string | image_tag
ParametersTypeRequiredDescription
widthnumberNoThe width of the image.
heightnumberNoThe height of the image.
sizesnumberNoThe source sizes for responsiveness.
widthsnumberNoThe widths to associate with custom `srcset` values.
srcsetnumberNoThe `srcset` for responsiveness.
preloadbooleanNoWhether the resource should be preloaded.
altnumberNoThe image's alt text.
Example
{{ product | image_url: width: 200 | image_tag }}
Example — `image_tag` and focal points
{{ images['potions-header.png'] | image_url: width: 300 | image_tag }}

image_url

Returns the CDN URL for an image.

Returns: string

Syntax
variable | image_url: width: number, height: number
ParametersTypeRequiredDescription
cropstringNoHow the image should be cropped to match the desired dimensions.
formatstringNoThe file format for the image.
pad_colorstringNoThe padding color, if the provided image is smaller than the requested dimensions.
widthnumberYesThe desired image width, in pixels.
heightnumberYesThe desired image height, in pixels.
Example
{{ product | image_url: width: 450 }}
Example — width
{{ product | image_url: width: 450 }}

img_tagDeprecated

Generates an HTML `<img>` tag for a given image URL.

Returns: string

Syntax
string | img_tag
ParametersTypeRequiredDescription
altstringNoThe image's alt text.
classstringNoThe desired `class` attribute.
sizestringNoThe desired image size.
Example
{{ product | img_tag }}
Example — Optional parameters
{{ product | img_tag: 'image alt text', '', '450x450' }}

img_urlDeprecated

Returns the CDN URL for an image.

Returns: string

Syntax
variable | img_url
ParametersTypeRequiredDescription
sizestringNoThe desired image size.
cropstringNoThe part of the image to show if the specified image has an aspect ratio that differs from the original.
scalenumberNoThe desired pixel density.
formatstringNoThe desired image format.
Example
{{ product | img_url }}
Example — size
{{ 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

Syntax
asset_name | inline_asset_content
Example
{{ 'icon.svg' | inline_asset_content }}

item_count_for_variant

Returns the total item count for a specified variant in the `cart` object.

Returns: number

Syntax
cart | item_count_for_variant: {variant_id}
Example
{{ 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

Syntax
array | join
Example
{{ collection.all_tags | join }}
Example — Custom separator
{{ collection.all_tags | join: ', ' }}

json

Converts a string, or object, into JSON format.

Returns: string

Syntax
variable | json
Example
{{ product | json }}

last

Returns the last item in an array.

Returns: untyped

Syntax
array | last
Example
{%- assign last_product = collection.products | last -%}

{{ last_product.title }}
Example — Dot notation
{{ 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>

Syntax
cart | line_items_for: object
Example
{% assign product = all_products['bloodroot-whole'] %}
{% assign line_items = cart | line_items_for: product %}

Total cart quantity for product: {{ line_items | sum: 'quantity' }}
Example
{% 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' }}

lstrip

Strips all whitespace from the left of a string.

Returns: string

Syntax
string | lstrip
Example
{%- 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>

Syntax
array | map: string
Example
{%- 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

Syntax
string | md5
Example
{{ '' | md5 }}

media_tag

Generates an appropriate HTML tag for a given media object.

Returns: string

Syntax
media | media_tag
ParametersTypeRequiredDescription
image_sizestringNoThe dimensions of the media's poster image.
Example
{% for media in product.media %}
  {{- media | media_tag }}
{% endfor %}
Example — image_size
{% 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

Syntax
metafield | metafield_tag
ParametersTypeRequiredDescription
fieldstringNoSpecifies which field should be used. Only applicable to `list.metaobject_reference` and `metaobject_reference` types.
list_formatstringNoThe desired list format. Accepts `unordered` or `ordered`. Default: `unordered`.
Example — Basic types
&lt;!-- boolean --&gt;
{{ product.metafields.information.seasonal | metafield_tag }}

&lt;!-- collection_reference --&gt;
{{ product.metafields.information.related_collection | metafield_tag }}

&lt;!-- color --&gt;
{{ product.metafields.details.potion_color | metafield_tag }}

&lt;!-- date --&gt;
{{ product.metafields.information.expiry | metafield_tag }}

&lt;!-- date_time --&gt;
{{ product.metafields.information.brew_date | metafield_tag }}

&lt;!-- json --&gt;
{{ product.metafields.information.burn_temperature | metafield_tag }}

&lt;!-- money --&gt;
{{ product.metafields.details.price_per_ml | metafield_tag }}

&lt;!-- multi_line_text_field --&gt;
{{ product.metafields.information.shipping | metafield_tag }}

&lt;!-- number_decimal --&gt;
{{ product.metafields.information.salinity | metafield_tag }}

&lt;!-- number_integer --&gt;
{{ product.metafields.information.doses_per_day | metafield_tag }}

&lt;!-- page_reference --&gt;
{{ product.metafields.information.dosage | metafield_tag }}

&lt;!-- product_reference --&gt;
{{ product.metafields.information.related_product | metafield_tag }}

&lt;!-- rating --&gt;
{{ product.metafields.details.rating | metafield_tag }}

&lt;!-- single_line_text_field --&gt;
{{ product.metafields.information.directions | metafield_tag }}

&lt;!-- url --&gt;
{{ product.metafields.information.health | metafield_tag }}

&lt;!-- variant_reference --&gt;
{{ product.metafields.information.best_seller | metafield_tag }}

&lt;!-- rich_text_field --&gt;
{{ product.metafields.information.rich_description | metafield_tag }}
Example — dimension
{{ product.metafields.details.scale_width | metafield_tag }}

metafield_text

Generates a text version of the data from a `metafield` object.

Returns: string

Syntax
metafield | metafield_text
ParametersTypeRequiredDescription
fieldstringNoSpecifies which field should be used. Only applicable to types `list.metaobject_reference` and `metaobject_reference`.
Example — Basic types
{{ product.metafields.information.dosage | metafield_text }}
Example — list.metaobject_reference
{{ product.metafields.information.ingredients | metafield_text: field: 'name' }}

minus

Subtracts a given number from another number.

Returns: number

Syntax
number | minus: number
Example
{{ 4 | minus: 2 }}

model_viewer_tag

Generates a Google model viewer component for a given 3D model.

Returns: string

Syntax
media | model_viewer_tag
ParametersTypeRequiredDescription
image_sizestringNoThe dimensions of the model viewer's poster image.
Example
{% for media in product.media %}
  {% if media.media_type == 'model' %}
    {{ media | model_viewer_tag }}
  {% endif %}
{% endfor %}
Example — Model viewer attributes
{% 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

Syntax
number | modulo: number
Example
{{ 12 | modulo: 5 }}

money

Formats a given price based on the store's **HTML without currency** setting.

Returns: string

Syntax
number | money
Example
{{ product.price | money }}

money_amount

Formats a given price as a plain decimal string, without currency symbols, thousand separators, or locale formatting.

Returns: string

Syntax
number | money_amount
Example
{{ product.price | money_amount }}

money_with_currency

Formats a given price based on the store's **HTML with currency** setting.

Returns: string

Syntax
number | money_with_currency
Example
{{ 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

Syntax
number | money_without_currency
Example
{{ 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

Syntax
number | money_without_trailing_zeros
Example
{{ product.price | money_without_trailing_zeros }}

newline_to_br

Converts newlines (`\n`) in a string to HTML line breaks (`<br>`).

Returns: string

Syntax
string | newline_to_br
Example
{{ product.description | newline_to_br }}

placeholder_svg_tag

Generates an HTML `<svg>` tag for a given placeholder name.

Returns: string

Syntax
string | placeholder_svg_tag
ParametersTypeRequiredDescription
classstringNoThe desired `class` attribute.
Example
{{ 'collection-1' | placeholder_svg_tag }}
Example — class
{{ 'collection-1' | placeholder_svg_tag: 'custom-class' }}

pluralize

Outputs the singular or plural version of a string based on a given number.

Returns: string

Syntax
number | pluralize: string, string
Example
Cart item count: {{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }}

plus

Adds two numbers.

Returns: number

Syntax
number | plus: number
Example
{{ 2 | plus: 2 }}

preload_tag

Returns: string

Syntax
string | preload_tag: as: string
ParametersTypeRequiredDescription
asstringYesThe type of element or resource to preload.
Example
{{ 'cart.js' | asset_url | preload_tag: as: 'script' }}
Example — HTML attributes
{{ 'cart.js' | asset_url | preload_tag: as: 'script', type: 'text/javascript' }}

prepend

Adds a given string to the beginning of a string.

Returns: string

Syntax
string | prepend: string
Example
{%- assign origin = request.origin -%}

{{ product.url | prepend: origin }}

product_img_urlDeprecated

Returns the CDN URL for a product image.

Returns: string

Syntax
variable | product_img_url
ParametersTypeRequiredDescription
sizestringNoThe desired image size.
Example
{{ product.featured_image | product_img_url }}
Example — The size parameter
{{ product.images[0] | product_img_url: 'large' }}

reject

Filters an array to exclude items with a specific property value.

Returns: array<untyped>

Syntax
array | reject: string, string
Example
{% 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

Syntax
string | remove: string
Example
{{ "I can't do it!" | remove: "'t" }}

remove_first

Removes the first instance of a substring inside a string.

Returns: string

Syntax
string | remove_first: string
Example
{{ "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

Syntax
string | remove_last: string
Example
{{ "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

Syntax
string | replace: string, string
Example
{{ product.handle | replace: '-', ' ' }}

replace_first

Replaces the first instance of a substring inside a string with a given string.

Returns: string

Syntax
string | replace_first: string, string
Example
{{ product.handle | replace_first: '-', ' ' }}

replace_last

Replaces the last instance of a substring inside a string with a given string.

Returns: string

Syntax
string | replace_last: string, string
Example
{{ product.handle | replace_last: '-', ' ' }}

reverse

Reverses the order of the items in an array.

Returns: array<untyped>

Syntax
array | reverse
Example
Original order:
{{ collection.products | map: 'title' | join: ', ' }}

Reverse order:
{{ collection.products | reverse | map: 'title' | join: ', ' }}
Example — Reversing strings
{{ collection.title | split: '' | reverse | join: '' }}

round

Rounds a number to the nearest integer.

Returns: number

Syntax
number | round
Example
{{ 2.7 | round }}
{{ 1.3 | round }}
Example — Round to a specific number of decimal places
{{ 3.14159 | round: 2 }}

rstrip

Strips all whitespace from the right of a string.

Returns: string

Syntax
string | rstrip
Example
{%- 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

Syntax
string | script_tag
Example
{{ '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

Syntax
string | sha1: string
Example
{%- 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

Syntax
string | sha256: string
Example
{%- assign secret_potion = 'Polyjuice' | sha256 -%}

My secret potion: {{ secret_potion }}

size

Returns the size of a string or array.

Returns: number

Syntax
variable | size
Example
{{ collection.title | size }}
{{ collection.products | size }}
Example — Dot notation
{% if collection.products.size &gt;= 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

Syntax
string | slice
Example
{{ collection.title | slice: 0 }}
{{ collection.title | slice: 0, 5 }}

{{ collection.all_tags | slice: 1, 2 | join: ', ' }}
Example — Negative index
{{ collection.title | slice: -3, 3 }}

sort

Sorts the items in an array in case-sensitive alphabetical, or numerical, order.

Returns: array<untyped>

Syntax
array | sort
Example
{% assign tags = collection.all_tags | sort %}

{% for tag in tags -%}
  {{ tag }}
{%- endfor %}
Example — Sort by an array item property
{% 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

Syntax
string | sort_by: string
Example
{{ collection.url | sort_by: 'best-selling' }}

sort_natural

Sorts the items in an array in case-insensitive alphabetical order.

Returns: array<untyped>

Syntax
array | sort_natural
Example
{% assign tags = collection.all_tags | sort_natural %}

{% for tag in tags -%}
  {{ tag }}
{%- endfor %}
Example — Sort by an array item property
{% 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>

Syntax
string | split: string
Example
{%- 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

Syntax
string | strip
Example
{%- assign text = '  Some potions create whitespace.      ' -%}

"{{ text }}"
"{{ text | strip }}"

strip_html

Strips all HTML tags from a string.

Returns: string

Syntax
string | strip_html
Example
&lt;!-- With HTML --&gt;
{{ product.description }}

&lt;!-- HTML stripped --&gt;
{{ product.description | strip_html }}

strip_newlines

Strips all newline characters (line breaks) from a string.

Returns: string

Syntax
string | strip_newlines
Example
&lt;!-- With newlines --&gt;
{{ product.description }}

&lt;!-- Newlines stripped --&gt;
{{ product.description | strip_newlines }}

structured_data

Converts an object into a schema.org structured data format.

Returns: string

Syntax
variable | structured_data
Example
&lt;script type="application/ld+json"&gt;
  {{ product | structured_data }}
&lt;/script&gt;

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

Syntax
string | stylesheet_tag
ParametersTypeRequiredDescription
mediastringNoThe type of media that the resource applies to.
preloadbooleanNoWhether the resource should be preloaded.
Example
{{ 'base.css' | asset_url | stylesheet_tag }}
Example — preload
stylesheet_url | stylesheet_tag: preload: boolean

sum

Returns the sum of all elements in an array.

Returns: number

Syntax
array | sum
Example
{% assign fibonacci = '0, 1, 1, 2, 3, 5' | split: ', ' %}

{{ fibonacci | sum }}
Example — Sum object property values
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

Syntax
string | time_tag: string
ParametersTypeRequiredDescription
formatstringNoThe desired date format.
datetimestringNoThe format for the datetime attribute of the time element.
Example
{{ article.created_at | time_tag: '%B %d, %Y' }}
Example — format
{{ article.created_at | time_tag: format: 'abbreviated_date' }}

times

Multiplies a number by a given number.

Returns: number

Syntax
number | times: number
Example
{{ 2 | times: 2 }}

translate

Returns a string of translated text for a given translation key from a locale file.

Alias: t

Returns: string

Syntax
string | t

truncate

Truncates a string down to a given number of characters.

Returns: string

Syntax
string | truncate: number
Example
{{ article.title | truncate: 15 }}
Example — Specify a custom ellipsis
{{ article.title | truncate: 15, '--' }}
{{ article.title | truncate: 15, '' }}

truncatewords

Truncates a string down to a given number of words.

Returns: string

Syntax
string | truncatewords: number
Example
{{ article.content | strip_html | truncatewords: 15 }}
Example — Specify a custom ellipsis
{{ article.content | strip_html | truncatewords: 15, '--' }}

{{ article.content | strip_html | truncatewords: 15, '' }}

uniq

Removes any duplicate items in an array.

Returns: array<untyped>

Syntax
array | uniq
Example
{% 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

Syntax
number | unit_price_with_measurement: unit_price_measurement
Example
{%- assign variant = product.variants.first -%}

{{ variant.unit_price | unit_price_with_measurement: variant.unit_price_measurement }}
Example — Formatted unit price
{%- 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

Syntax
string | upcase
Example
{{ product.title | upcase }}

url_decode

Decodes any percent-encoded characters in a string.

Returns: string

Syntax
string | url_decode
Example
{{ 'test%40test.com' | url_decode }}

url_encode

Converts any URL-unsafe characters in a string to the percent-encoded equivalent.

Returns: string

Syntax
string | url_encode
Example
{{ '[email protected]' | url_encode }}

url_escape

Escapes any URL-unsafe characters in a string.

Returns: string

Syntax
string | url_escape
Example
{{ '&lt;p&gt;Health &amp; Love potions&lt;/p&gt;' | url_escape }}

url_for_type

Generates a URL for a collection page that lists all products of the given product type.

Returns: string

Syntax
string | url_for_type
Example
{{ '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

Syntax
string | url_for_vendor
Example
{{ "Polina's Potent Potions" | url_for_vendor }}

url_param_escape

Escapes any characters in a string that are unsafe for URL parameters.

Returns: string

Syntax
string | url_param_escape
Example
{{ '&lt;p&gt;Health &amp; Love potions&lt;/p&gt;' | url_param_escape }}

video_tag

Generates an HTML `<video>` tag for a given video.

Returns: string

Syntax
media | video_tag
ParametersTypeRequiredDescription
image_sizestringNoThe dimensions of the video's poster image.
Example
{% for media in product.media %}
  {% if media.media_type == 'video' %}
    {{ media | video_tag }}
  {% endif %}
{% endfor %}
Example — image_size
{% for media in product.media %}
  {% if media.media_type == 'video' %}
    {{ media | video_tag: image_size: '400x' }}
  {% endif %}
{% endfor %}

weight_with_unit

Returns: string

Syntax
number | weight_with_unit
ParametersTypeRequiredDescription
weight_unitstringNoThe weight unit to use in place of the default weight unit.
Example
{%- assign variant = product.variants.first -%}

{{ variant.weight | weight_with_unit }}
Example — Override the default 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>

Syntax
array | where: string, string
Example
{% 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 %}
Example — Filter for boolean properties with a `true` value
{% 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

Syntax
string | within: collection
Example
{%- assign collection_product = collection.products.first -%}

{{ collection_product.url | within: collection }}