Object descriptors
Handles are used to access Liquid objects. By default, a handle is the object name, presented in lowercase with spaces and other characters replaced by hyphens (-).
For example, a page called "About Us" can be retrieved from the Liquid file using the "about-us" descriptor, as shown below:
<!-- The content of the page "About us" -->
{{ pages['about-us'].content }}
In this article
How descriptors are created
A page named "Shirt" will automatically be assigned the "shirt" descriptor. If another page was previously assigned the "shirt" descriptor, the newly created page will use the automatic increment. In other words, new pages named "Shirt" will be assigned the "shirt-1" or "shirt-2" descriptor, etc.
When creating a descriptor, a space in the page name is replaced with a dash. For example, a page called "New T-Shirt Name" will automatically be assigned the descriptor "new-t-shirt-name".
The descriptor also defines the URL of the page. For example, a page with the descriptor "white-shirt" would have the URL https://my-shop.myshopify.com/pages/white-shirt.
In Shopify themes, developers often use static handles for pages, products, or menus. To preserve the functionality of the design element and features, Shopify does not change the handle when the name of the object (page, product, menu, etc.) changes.
That is, if you change the page name from "About us" to "Our company", the descriptor will remain the same - "about-us". If necessary, you can change the descriptor manually.
Accessing descriptor attributes
In many cases, you know the name of the handle to the object you want to access. To use it, you can use one of the methods for accessing the object - using square brackets (["handle"]) or using dot notation (.handle).
{{ pages['about-us'].title }}
{{ pages.about-us.title }}
In both cases, the code will display the page title:
About us
About us
Note that the handle is requested from the pages object, not the page.
Instead of specifying the descriptor directly, you can also specify an object from the theme editor. This feature is useful for developers who want to give their theme users the ability to choose what content to display in their theme.
{% for product in collections[settings.home_featured_collection].products %}
{{ product.title }}
{% endfor %}