Demystifying Liquid Markup: Output vs. Tag | A New Series Begins!

Elghorfi Mohamed
1 min readDec 8, 2023

--

Let’s Unify Our Knowledge: A New Series Begins!

In the world of Liquid templates, understanding the difference between output markup and tag markup is crucial for building dynamic and efficient content.

Output markup:

  • Wrapped in double curly braces {{ }}
  • Resolves to text, values, or expressions

Examples:

  • Hello{{ name }}: Outputs the value of the name variable
  • Hello {{ user.name }}: Outputs the name property of the user object
  • Hello {{ 'Mohamed' }} : Outputs the literal string 'Mohamed'

Tag markup:

  • Wrapped in double curly braces and percent signs {% %}
  • Cannot resolve to text directly
  • Used for logic control, loops, and other functionalities

Examples:

  • {% if user.role == 'admin' %} .... {% endif %}: Conditional statement
  • {% for user in users %} .... {% endfor %}: Looping through an array
  • {% assign name = 'Mohamed' %}: Assigning a value to a variable

By mastering these two types of markup, you can unlock the full potential of Liquid and craft robust, dynamic content for your online projects.

#liquidlang #webdev #templating #developerlife #learnsomethingnew

Is Liquid a part of your development toolkit? Share your experiences in the comments!

--

--

Elghorfi Mohamed

Frontend || Shopify Expert Developer || Shopify Consulting