{% include %}
Processes and outputs a partial template, javascript, or stylesheet. If the partial template is a compiled template, then any custom fields from the partial template will be available in the parent template as well.
{% include [template|javascript|stylesheet]? variable =? attributes? %}
Parameters
type
optionalstring
Explicit type selector: template, javascript, or stylesheet. If not specified, the object to be included will be the same as the type of the current object (in a template this will default to template, etc...).
variable
requiredobject
May be the template, javascript, or stylesheet object to include, the unique identifier for the object to include, or the absolute or relative path to the template, javascript, or stylesheet
attributes
optionaldictionary
Key:value pairs with unique keys. May use the variable arguments syntax. Variables to set on the created scope before the included object is processed
This method creates a new liquid context for storing and manipulating variables.
The text after include is a path (or an object, or a GUID). Every template, javascript and stylesheet has a path, even if that is the root path (/), and a name; together they identify it, for example /sections/_banner.liquid. A path can be absolute or relative. An absolute path begins with / and is taken from the root, whatever template is doing the including: {% include '/partials/header.liquid' %}. A relative path does not begin with / and is resolved against the folder of the template being rendered: including 'header.liquid' from a template in /pages processes /pages/header.liquid, and the same include from a template at the root processes /header.liquid. Inside an included template, relative means relative to that template's own folder, not the page's. .. moves up one folder, so '../partials/header.liquid' from a template in /agency/pages processes /agency/partials/header.liquid, and any .. beyond the root is ignored. ./ is not supported: the leading . is read as a folder named '.', which matches nothing, so write 'header.liquid' for a template in the current folder. The name is matched as stored, with no extension added or removed, so keep the .liquid ending when the template's name has one. Instead of a path you can pass the object itself or its GUID; either skips path resolution, and with no type keyword the type is the type of the template currently being rendered. When nothing matches, the live site outputs a comment naming the full path that was looked up (a /** */ comment for a stylesheet or javascript) rather than stopping the page, and preview raises an error instead. The list methods {% templates %}, {% stylesheets %} and {% javascripts %} read paths differently: from the root only, never relative.