🔧Tags for Includes

The Include Tag and Custom Paths

The Liquid tag include is usually used to insert a Liquid Partial into a Liquid File.

Sometimes this can link to one of your files directly, simply pass in a String containing a custom path to your file. The path must start relative to the partials folder and must not include the file extension:

đŸŒŗIncludes File Structure

Sometimes it will link to a hidden Siteglide Module file, which may in turn include one of your customisable "layout" Liquid files.

Types of Include

To include one of Site's common include types, use these below and pass in the ID of the include (or the filename without the extension which will be the same). Name is a completely optional parameter.

{% include 'header', id: '1', name: 'optional to help code readability' %}
{% include 'footer', id: '1', name: 'optional to help code readability' %}
{% include 'content_section', id: '1', name: 'optional to help code readability' %}
{% include 'code_snippet', id: '1', name: 'optional to help code readability' %}

Inheritance

The include tag will always pass down all variables initiated above it to the file that has been included.

These can be either implicit or explicitly passed:

{% assign implicit_variable = 'a' %}
{% include 'my_file', explicit_variable: 'b' %}
{% assign varible_with_no_scope = 'c' %}

For this example, implicit_variable and explicit_variable will have scope inside the partial file when it is rendered, but varible_with_no_scope will not, simply because it is initialised after the include tag in the page.

There are also alternative tags which have a different inheritance behaviour:

If you want to pass variables from the partial file up to the page, you need to use either of these methods:

Last updated