Questions tagged [liquid]

Liquid is an open-source template language created by Shopify and written in Ruby. It is the backbone of Shopify themes and is used to load dynamic content on storefronts. Liquid has been in production use at Shopify since 2006 and is now used by many other hosted web applications.

Liquid is a templating engine for creating web pages. From the Liquid website:

Liquid is an extraction from the e-commerce system Shopify. Shopify powers many thousands of e-commerce stores which all call for unique designs. For this we developed Liquid which allows our customers complete design freedom while maintaining the integrity of our servers.

Liquid has been in production use since June 2006 and is now used by many other hosted web applications.

It was developed to for usage in Ruby on Rails web applications and integrates seamlessly as a plugin but it also works excellently as a stand alone library.

In addition, Liquid is also used as the main templating engine on GitHub pages through the Jekyll static site generator.

3995 questions
51
votes
2 answers

Liquid templates: even/odd items in for loop

If I have a for loop in Liquid (using Jekyll), how can I target even (or odd) items only? I have tried: {% for item in site.posts %} {% if forloop.index % 2 == 1 %} but that doesn't seem to work. I have also tried: (forloop.index % 2) ==…
Adam Kiss
  • 11,811
  • 9
  • 48
  • 81
49
votes
8 answers

An easy way to support tags in a jekyll blog

I am using the standard jekyll installation to maintain a blog, everything is going fine. Except I would really like to tag my posts. I can tag a post using the YAML front matter, but how do I generate pages for each tag that can will list all…
raheel
  • 1,407
  • 1
  • 15
  • 24
46
votes
5 answers

Enabling Liquid templating syntax highlight in webStorm/phpStorm

I wonder if someone managed to enable the Liquid templating engine syntax highlighting in WebStorm IDE, I work a lot on Shopify stores and really like using Webstorm for that purpose. Did anyone managed to get this working? I found some resources…
Ilia luk
  • 2,065
  • 2
  • 16
  • 18
44
votes
1 answer

Is there a "break" tag to escape a loop in Liquid?

How do I break out of loop in Liquid, mainly a for-loop? I've tried {% break %}, but that fails with There were errors saving your file: Unknown tag 'break'. I'm trying to achieve something like: var variants = []; {% for item in cart.items %} …
Lekensteyn
  • 64,486
  • 22
  • 159
  • 192
42
votes
4 answers

How to adjust Jekyll post order?

I have started a Jekyll based blog with a theme jekyll-now. I am new to Jekyll and how it operates (especially Liquid). I understand that new posts need to be as follows: 2014-10-04-Hello-World.md. But I really don't understand how I could order…
Koxzi
  • 1,021
  • 1
  • 10
  • 21
42
votes
4 answers

Include jekyll / liquid template data in a YAML variable?

I am using the YAML heading of a markdown file to add an excerpt variable to blog posts that I can use elsewhere. In one of these excerpts I refer to an earlier blog post via markdown link markup, and I use the liquid template data variable {{…
Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453
40
votes
4 answers

Assign an array literal to a variable in Liquid Template

The only way i know to create an array from my liquid template is: {% assign my_array = "one|two|three" | split: "|" %} Is there any other way to do it?
Stefano Ortisi
  • 5,288
  • 3
  • 33
  • 41
38
votes
2 answers

How to use multiple arguments in an if statement with Liquid

I want to use an if statement in Liquid with multiple conditionals. Something like: {% if (include.featured == "true" and product.featured == "true") or (include.featured == "false" and product.featured == "false") %} Multiple conditionals don't…
Fisu
  • 3,294
  • 9
  • 39
  • 61
35
votes
5 answers

Outputting Literal curly braces in Liquid templates

I'm trying to output the following from within a liquid template: {{ example }} Obviously, Liquid sees this as a variable named example and tries to do substitution. I'm trying to find out how I can output the actual braces. So far, I've found one…
Fortes
  • 1,436
  • 2
  • 12
  • 14
35
votes
9 answers

How to list files in a directory with Liquid?

I'm trying to learn how to use Jekyll along with Bootstrap; while studying them, I decided that I'd like to have an image carousel on my homepage. Since I'm really lazy I don't want to hard-code the paths needed to display every image inside the…
Cesco
  • 3,770
  • 7
  • 24
  • 26
34
votes
1 answer

Including HTML inside Jekyll tag

Instead of writing out {% include link_to.html i=5 text="hello world" %} all the time, I've written a custom tag that allows me to do {% link_to 5 hello world %}. It finds the page with data i equal to 5 and creates a link to it. But it feels clunky…
wrongusername
  • 18,564
  • 40
  • 130
  • 214
34
votes
6 answers

Jekyll — Change layout if page is a post?

In a Jekyll layout, is there any way to detect if the page is a normal page or a post? I want to display post titles, but not page titles. Like this: {% if page.is_post? %}

{{ page.title }}

{% endif %} {{ content }}
Zaz
  • 46,476
  • 14
  • 84
  • 101
31
votes
4 answers

Jekyll Paginator not working

I am currently working on a jekyll based homepage and I cant get pagination working.
30
votes
5 answers

How to show the modification date of a file in Jekyll?

I know that I can specify a variable date in the YAML frontmatter of a file and access its value with {{ page.date }}. This is cumbersome since one easily forgets to change the date when a file is updated. So how can I access a file's modification…
Robert
  • 872
  • 3
  • 10
  • 15
29
votes
9 answers

Shopify Theme with Compass and Sass

Does anyone have a workflow for developing Shopify themes with Compass and Sass? I am really close, I just need to figure out how to not make Sass barf on the CSS liquid tags. Here's what I've got: A sass/compass project in directory (ex:,…
wart
  • 610
  • 1
  • 6
  • 10