Variable tags
Variable tags are used to create new Liquid variables.
assign
Creates a new variable. Assignments can also use filters to modify the value.
Code
{% assign is_valid = true %}
{% if is_valid %}
It is valid.
{% endif %}
{% assign name = dave bowman' | upcase %}
{{ name }}
Output
It is valid.
DAVE BOWMAN
capture
Captures the content within its block and assigns it to a variable. This content can then be rendered later by using output tags.
Code
{% capture hello %}Hello, {{ user.fullname }}.{% endcapture %}
{{ hello }}
{{ hello }}
Output
Hello, DAVE BOWMAN.
Hello, DAVE BOWMAN.
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for