Skip to content

template

The global template object identifies the template selected for the current storefront render. It contains normalized template metadata, not the template source or filesystem path.

Example

<body
data-template="{{ template.name }}"
{% if template.suffix %}data-template-suffix="{{ template.suffix }}"{% endif %}
>

For templates/product.featured.json, template.name is product, template.suffix is featured, and template.directory is nil. For a nested metaobject template such as templates/metaobject/article.alternate.json, the name is article, the suffix is alternate, and the directory is metaobject. Customer-account documents are system-owned and are not theme templates.

Properties

PropertyDescription
template.directoryTemplate subdirectory such as metaobject, or nil for a top-level template.
template.nameBase template name such as product, collection, or index.
template.suffixAlternate template suffix, or nil for the default template.

Property list is generated from the storefront engine (TemplateDrop), so it always matches what your theme can use. Use {{ template | json }} only as a curated debug snapshot; it can omit lazy or otherwise public properties.