Variables

Variable tags create new Liquid variables. Here are the two most common tags but you can learn more in the official documentation.

assign

Read the complete assign documentation.

Creates a new named variable.

Input
{% assign foo = "bar" %}
{{foo}}
Output
bar

capture

Read the complete capture documentation.

Captures the string inside of the opening and closing tags and assigns it to a variable. Variables created using capture are stored as strings.

Input
{% assign favorite_food = "pizza" %}
{% assign age = 35 %}

{% capture about_me %}
I am {{age}} and my favorite food is {{favorite_food}}.
{% endcapture %}

{{about_me}}
Output
I am 35 and my favourite food is pizza.

Last updated