Handles
Object handles
Objects represent store resources, such as products, collections, articles, and blogs, and have handles for identifying an individual resource. The handle is used to build the URL for the resource or to return properties for the resource.
Creating and modifying handles
Handles are automatically generated based on the resource title. They follow a set of rules:
- Handles are always lowercase
- whitespace and special characters (
?
,#
, etc.) are replaced with a hyphen-
. - If there are multiple consecutive whitespace or special characters, then they're replaced with a single hyphen.
- Whitespace or special characters at the beginning are removed.
Handles need to be unique, so if a duplicate title is used, then the handle is auto-incremented by one. For example, if you had two products called Ace Cashmere Beanie
, then their handles would be ace-cashmere-beanie
and ace-cashmere-beanie-1
.
{{ product.title | handle }}
{
"product": {
"title": "Ace Cashmere Beanie"
}
}
ace-cashmere-beanie
Referencing handles
Some objects(e.g. product, collection, etc.)that have a handle have a handle
property. For example, you can output a product's handle with theproduct.handle
.
Updated over 1 year ago