Liquid Views
Include
The include tag includes content and liquid snippets from other files in the current file.
Example
Note that you don't need to write the file's extension, although you can include it if needed.
When you include a file, the code inside it will have access to the variables within its parent template.
Including multiple variables in a snippet
There are two ways to include multiple variables in a snippet. You can assign and include them on different lines, which creates them in the parent template:
Or you can create variables on the same line where you include the snippet:
include
tag parameters
with
The with parameter assigns a value to a variable inside a snippet that shares the same name as the snippet.
For example, if you have a file named color.liquid
which contains the following:
Within the parent file, you can include the color.liquid
file as follows:
Input
Output
color: '' shape: 'circle'
color: 'red' shape: 'circle'
color: 'blue' shape: 'circle'
color: 'red' shape: 'square'
Last updated: 06/20/2019