find
Finds the first item in an array where a property matches a given value. Returns null if no match is found.
{% assign product = products | find: "sku", "ABC123" %}
{% log product.title %}Syntax
{{ array | find: property, value }}Parameter
Description
array
Array of objects to search
property
Property name to match against (supports nested properties via dot notation)
value
Value to compare against
Return Value
Returns the first matching item, or null if no item matches.
Examples
Find a product by SKU:
{% assign product = products | find: "sku", "T-SHIRT-RED-M" %}
{% if product %}
{% log "Found: " | append: product.title %}
{% else %}
{% log "Product not found" %}
{% endif %}Find an order by name:
Find by nested property:
Find a customer by email:
Notes
Returns the first matching item — if multiple items match, only the first is returned
Uses loose equality (
==) for comparisonSupports dot notation for nested properties:
"node.title","address.city"For more complex matching conditions, use
find_expFor building a reusable lookup by property, consider
index_byinstead
Last updated