An introduction to objects

Objects in Twig contain attributes which output dynamic content on the given page.

For example, the product object contains an attribute called title that can be used to output the title/name of the product being viewed.

Often, you may find that objects and their attributes are referred to as variables. These terms are used interchangeably.

To output the attribute of an object, the variable is wrapped in {{ and }}, for example

{{ product.title }}

returns

Nike white trainers

The output of objects and their attributes can be modified with filters, for example

{{ product.title|capitalize }}

returns

NIKE WHITE TRAINERS

Filters are placed within an output tag (i.e. {{ }} ) and are denoted with the pipe character |. You can read more about filters in the full article by clicking here.

The output of objects can also be modified, in a similar way, using functions.


Types of objects

There are essentially two types of objects available on the platform.

Global Objects which are a set of objects which are available on any file/view in your theme.

Other Objects which are objects only available on specific files/views. The other objects are documented in the subsequent help pages of this section.