Objects
Objects are the data that you have to work with within your Live Editor theme.
Objects are containers for dynamic data that you’ll have to work with in your theme’s Liquid templates.
Sometimes the objects will have attributes for you to work with. You can access attributes with dot notation:
And sometimes the objects will contain a simple value like a string or date, which you can filter or output directly:
There are 3 types of objects:
Global Objects
These objects are available within every template, no matter the context (e.g., page
represents the current page, and you’ll always be on a page).
-
canonical_url
- Canonical URL configured for the current page that the user is accessing.
-
now
- Date object containing the current date and time.
-
page
- The current page that the user is accessing.
-
page_description
- Meta description of the current page that the user is accessing.
-
page_keywords
- Meta keywords of the current page that the user is accessing.
-
page_robots
-
Shortcut for outputting
robots
directives for<meta name="robots">
HTML tag. -
page_title
- Title of the current page that the user is accessing.
-
site
- The current site that the user is accessing.
Contextual Objects
These objects are available only within certain contexts (e.g., forloop
is only
available when you’re within a
for
loop block).
-
forloop
-
Used inside of a
for
loop block, provides data about the collection being looped over and the current iteration of the loop. -
navigation
- Used inside of a navigation template, provides data about the current navigation menu being referenced by the template.
Block Objects
While you’re authoring blocks within
content templates, you’ll
configure types of objects that will be available within the content templates’ displays.
For example, you may configure a block called photo
of type
image
, which has its own
set of attributes for you to reference within your Liquid code.
-
audio
- Audio file block for use within content template displays.
-
date
- Date/time object for use within content template displays.
-
embed_url
-
Data about a media URL to embed within an
<audio>
or<video>
tag. -
file
- File download block for use within content template displays.
-
image
- Image object for use within content template displays.
-
link
- Hyperlink object for use within content template displays.
-
text
- Text object for use within content template displays.
-
video
- Video object for use within content template displays.
Next steps
Continue your deep dive into Liquid with the Filters Reference.