Skip to main content

section

The properties and settings of a section.


Tip

To learn about sections and using them in a theme, refer to Sections.


Properties

Anchor to
blocks
array of block

The blocks of the section.

The ID of the section.

The ID for sections included through JSON templates are dynamically generated by Shopify.

The ID for static sections is the section file name without the .liquid extension. For example, a header.liquid section has an ID of header.

The 1-based index of the current section within its location.

Use this property to adjust section behavior based on its position within its location (template, section group) and on the page. The index starts at 1 within each location.

An example use case is for programmatically setting loading="lazy" for images below the fold based on an index higher than, for example, 3. Note that this is now the default behavior for the image_tag filter.

Only use this for non-display use cases like web performance. Because of various limitations, the index property returns nil in the following contexts:

The 0-based index of the current section within its location.

This is the same as the index property except that the index starts at 0 instead of 1.

The scope or context of the section (template, section group, or global).

Sections can have one of four different location types. For sections rendered within a template, the location will be template. For sections rendered within a section group, the location will be the section group type, e.g., header, footer, custom.<type>. Sections rendered statically will be static. Finally, if you're still using content_for_index, then the value will be content_for_index.

Anchor to
settings

The settings of the section.

To learn about how to access settings, refer to Access settings.

{
"blocks": [],
"id": "template--14453298921537__cart-items",
"settings": {}
}
Was this section helpful?