Handles

What is a handle?

The handle is used to access the attributes of a Liquid object. By default, it is the object's title in lowercase with any spaces and special characters replaced by hyphens (-). Every object in Liquid (product, collection, blog, link list) has a handle.

For example, a page with the title "About Us" can be accessed in Liquid via its handle about-us as shown below:

<!-- the content of the About Us page -->
{{ pages.about-us.content }}

How are my handles created?

A product with the title "Shirt" will automatically be given the handle shirt. If there is already a product with the handle "Shirt", the handle will auto-increment. In other words, all "Shirt" products created after the first one will receive the handle shirt-1, shirt-2, and so on.


Whitespaces in a title are replaced by hyphens in the handle. For example, the title "My Shiny New Title" will result in a handle called my-shiny-new-title.


The handle will also determine the URL of that object. For example, a page with the handle "about-us" would have the url: http://yourshop.myharavan.com/pages/about-us

Shop designs often rely on a static handle for a page, product, or linklist. In order to preserve design elements and avoid broken links, if you modify the title of an object, haravan will not automatically update the handle.

For example, if you were to change your page title from "About Us" to "About haravan" ...


... your handle will still be about-us.


However, you can change an object's handle manually by changing the value for the "URL & Handle" text box.


Accessing attributes via the handle

In many cases you may know the handle of a object whose attributes you want to access. You can access its attributes by pluralizing the name of the object, then using either the square bracket ( [ ] ) or dot ( . ) notation.

Input

{{ pages.about-us.title }} 
{{ pages["about-us"].title }}

Output

About Us
About Us

In the example above, notice that we are using pages as opposed to page.

You can also pass in Customize theme page objects using this notation. This is handy for theme designers who wish to give the users of their themes the ability to select which content to display in their theme.

Input

{% for product in collections[settings.home_featured_collection].products %}
    {{ product.title }}
{% endfor %}

Output

Awesome Shoes
Cool T-Shirt
Wicked Socks
Return to top