Change Log

  • 09-Jul-2025 | v7.3.5 | All new article

Contributors:

Adam Wilson - Logo Pogo

Liquid Miscellaneous

These liquid tags are used to alter or control the layout within the liquid scope.

include

Reference another file into the document structure, rendering its contents as if it were part of the document, including the parsing of Liquid.

The intended purpose of the include tag is to parse and combine smaller text-based layout components (.html, .css, .js, .inc, .layout...) into the container document to construct more complex or dynamic documents, or simply for a more modular code-base. While other file formats can be referenced, only their text-based/code content will be rendered, making the include tag unsuitable for images and other more complex document types.

{% assign documentName = "Include Sample" %}

<strong>Document: {{ documentName }}</strong><br>

{% include "/path/to/layout.inc" %}

<em>Footer of the {{ documentName }} document.</em>
Document: Include Sample
Contents of the `layout.inc` file for the document: "Include Sample".
Footer of the modified Include Sample document

The code in the layout.inc file looks like the below:

Contents of the `layout.inc` file for the document: "{{ documentName }}".
{% assign documentName | prepend: "modified " %}

Note, how the Liquid assign tag parses the value from the container document and in turn affects the Liquid further down in the container document.

comment

Omit content and Liquid parsing from the rendered document.

This provides server-side exclusion/commenting of code without the need to delete it or the risk of exposing unintended code publicly via the document source code.

{% assign myBoolean = true %}

<strong>Page Heading</strong>

{% comment %}
Some more unintended text here.
{% assign myBoolean = false %}
{% endcomment %}

Text that is intended to render ({{ myBoolean }}).
Page Heading
Text that is intended to render (true).

raw

Inhibits the parsing of Liquid tags that are wrapped within raw tags.

This allows you to render Liquid syntax as raw characters, without being processed within the Liquid scope. This is helpful in cases where you want to display the actual Liquid syntax to the user, such as in documentation, or when using other front-end templating languages that contain conflicting syntax (eg: Mustache or Handlebars).

{% raw %}
My name is {{myName}} which is stored in Handlebars (not Liquid).
We need it to render as-is in the HTML for Handlebars to process on the frontend.
{% endraw %}
My name is {{myName}} which is stored in Handlebars (not Liquid).
We need it to render as-is in the HTML for Handlebars to process on the frontend.