Liquid theme controller variables are globally accessible variables defined in a theme controller. They can be referenced across all parts of the theme, including pages, templates, and content blocks. These variables support static or dynamic assignment, and they support value reassignment.
Example:
controllers/theme
{% liquid
variables store_name: "Acme Store"
%}
Reference your variable:
{{ store_name }}
Output:
Acme Store
Important Notes
Global variables are part of a controller's actions and can only be declared within a controller file. One of their primary uses is to assign or reassign dynamic values.
You can reference theme controller variables anywhere in your theme, including within content objects like pages and content blocks. It's important to note that these variables are different from session variables: theme controller variables operate at the theme and server-side level, meaning their values are consistent across all users. In contrast, session variables are tied to an individual user's session and are only valid during that session.
Definitions
Controllers: In liquid themes, a controller is a theme component that helps to define and control global data or theme-related behaviour at a server-side level.
Server-side: Refers to data management that happens on the server before the theme is rendered and delivered to the user's browser.