{% assign %}

Saves a value to the root scope for later reference while removing it from any child scopes. Optionally applies filters to the value before assigning it to the variable.


{% assign [name] = [value] [| filter1 [: arg [arg...]]] [| filter2 ...] %}

name: The name of the variable to save the value to. If name starts with '&', will attempt to assign the value by reference.

value: The value to assign to the new variable.

May optionally include one or more filters.

The assign tag is superior to the var and set tags in that it guarantees both immediate and future access to the variable. It is inferior in that it is more likely to interfere with other template code due to naming collisions


Assign date add month and fetch calendar_entries

{% assign minDate = "now" | midnight %} {% assign maxDate = minDate | add_months: 1 %} {% calendar_entries output_to_template start_date:minDate end_date:maxDate limit:30 sort_by:"start_date" sort_direction:"asc" %}