handle

The handle object returns the handle of the following resources:

  • blogs
  • articles
  • collections
  • pages
  • products.

You can view and edit a resource's handle from the Shopify admin in the Search engine description section:

About us handle

You can use the handle object to target specific webpages. For example, you could add the following code to the theme.liquid template:

Input

{% if handle contains 'secret' %}
  <p>Shh! This is between you and us.</p>
{% endif %}

Output

<!-- On a page with a title of Top Secret, and a handle of top-secret -->
Shh! This is between you and us.

Webpages that don't have their own handle

Not all webpages have their own handle.

Your store's home page, which uses the template index.liquid, will not return any value for handle:

Input

{% if handle %}
  <p>You are either looking at a product, a collection, a page, a blog, or an article in a blog.<p>
{% else %}
  <p>You must be somewhere else. Hope you're having fun!</p>
{% endif %}

Output

<!-- On a store's home page -->
You must be somewhere else. Hope you're having fun!

Want to discuss this page?

Visit the Shopify Community