closest object
The nearest resource of each type for the section or block that is rendered.
Properties
| Name | Type | Description |
|---|---|---|
product | product | The nearest product |
collection | category | The nearest collection |
page | page | The nearest page |
blog | object | The nearest blog |
article | object | The nearest article |
Order
For each property, you get the first value found in this list:
- A setting of the same type on the section or block that is rendered:
product,collection,page,blogorarticle. - A
closest.argument on thecontent_fortag of the block, for exampleclosest.product: featured_product. - A setting of the same type on the nearest parent block, or on the section.
- The resource of the template, for example the product on a product page.
A setting with a dynamic source as its value is skipped, for example {{ closest.product }}.
liquid
{% if closest.product %}
<h2>{{ closest.product.title }}</h2>
{% endif %}