Web Island Agency

Liquid template language FAQ

Liquid template language FAQ

What is Liquid?

Liquid is a template language written in Ruby. It was created as a template engine for Shopify themes in 2006. Shared under the MIT license, Liquid has been migrating to other services and platforms.

What is Liquid code?

Liquid code has a Ruby-like syntax and mostly used together with HTML or any other markup language. Liquid extends HTML with variables, operators, flow control tags and filters. Generally, Liquid for HTML is the same as Sass for CSS.

What are the basic components of Liquid code?

The main components of Liquid code are objects, tags, and filters.

What is object in Liquid?

In Liquid, objects are used to store and show content. Calling an object within double curly braces will generate its content. For example:

{{ page.title }}

This input will generate content of the title property of the page object.

What is Liquid tag?

Tags bring the logic and control flow to the Liquid template. Liquid tags are wrapped with curly braces and percent signs. Tags don't produce any visible content, so nothing of the template logic is shown on the generated page.

Liquid tag use example:

{% if post.updated %}
  Updated on {{ post.updated }}
{% endif %}

What is Liquid filters?

Liquid filters are used to modify the output of an object. They are called within curly brakes right after the object prepended with |.

Liquid filter use example:

{{ "liquid" | capitalize }}

The code above will generate Liquid to output.

The article is published under the tags

Read more articles related to the topic