Variables
Variable tags create new Liquid variables. Here are the two most common tags but you can learn more in the official documentation.
Creates a new named variable.
Input
{% assign foo = "bar" %}
{{foo}}
Output
bar
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 modified 1yr ago