The include tag includes content and liquid snippets from other files in the current file.
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.
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:
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:
color: '' shape: 'circle' color: 'red' shape: 'circle' color: 'blue' shape: 'circle' color: 'red' shape: 'square'
Last updated: Fri 16 Mar, 2018