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
18
votes
1 answer

Using Liquid tags in a Jekyll page not working

I am attempting to setup a small blog using Jekyll. My work so far is as follows. Setup a Github pages repository Cloned the repo locally Installed Ruby vs 2 and the sdk (windows) Installed jekyll 'serve' the local website. Validated that I could…
nVentimiglia
  • 1,888
  • 4
  • 21
  • 37
17
votes
3 answers

Syntax Highlighting with Pygments is failing via Liquid Templates String Error

I'm using Jekyll to convert my markdown and Pygments for syntax highlighting. Here is the error maruku displays: Liquid error: undefined method `join' for "\n song_info = []\n for song in songs:\n song_info.append(song.name) \n":String The markup…
muffs
  • 805
  • 10
  • 14
17
votes
3 answers

Check if variable is type of string or array in liquid

In Jekyll you can use liquid template and I am trying to write a nav that includes all links in the website. sitemap: home: "/" demo: right: "/right" left: "/left" What I am trying to achieve is to create a sidebar that icludes all…
ctrlmaniac
  • 404
  • 4
  • 13
  • 28
17
votes
2 answers

loop through filtered collection in jekyll

I try to do things like this in my post:
    {% for post in site.posts | where:'group', post.group %}
    {% include article-snippet.html %}
    {% endfor %}
but…
Anton Shuvalov
  • 3,560
  • 3
  • 16
  • 20
16
votes
6 answers

Liquid: Can I get a random element from an Array?

I'm trying to pick a random element from an array -- is this possible using Liquid/Jekyll? I can create an array -- and access a given index ... but is there a way to "shuffle" the array and then select an index, and thus get a random element from…
rsturim
  • 6,756
  • 15
  • 47
  • 59
16
votes
4 answers

Make custom page-based loop in Jekyll

I would like to create another page-based loop, in the same way the _posts folder works for the blog section, but for a small catalogue of magazines. (Hopefully that makes sense) Maybe i'm misunderstanding something simple, but I just can't work it…
PaulAdamDavis
  • 1,574
  • 3
  • 16
  • 19
16
votes
5 answers

Jekyll, Liquid, Random numbers

I would like to have a set of links
  • Random Articles

  • But I want to generate the…
    randomlogic78
    • 279
    • 2
    • 8
    16
    votes
    2 answers

    Comparing dates in liquid

    I'm using Liquid with Jekyll to post dates on my band's website (http://longislandsound.com.au) What I want is to automatically hide old dates, so I don't have to go in and delete them again. I think the best way to do it would be to compare the…
    Chris Lawrence
    • 281
    • 1
    • 4
    • 7
    16
    votes
    2 answers

    Indenting generated markup in Jekyll/Ruby

    Well this is probably kind of a silly question but I'm wondering if there's any way to have the generated markup in Jekyll to preserve the indentation of the Liquid-tag. World doesn't end if it isn't solvable. I'm just curious since I like my code…
    russinkungen
    • 367
    • 4
    • 12
    15
    votes
    1 answer

    Rails End-User Templating Engines: Liquid vs Mustache vs. Others?

    I am creating a service in which I want to allow end-users to edit HTML templates for web pages that allows for access to specific "variables" for inclusion in the template. I know that liquid was designed for this very purpose, is secure (at least…
    marcusmateus
    • 153
    • 1
    • 6
    15
    votes
    3 answers

    Jekyll & Liquid: Output category list with post count?

    I'm somehow stuck and don't find the right way to do it. I want to output a category list with the number of posts in each categorie. I got this far: https://paste.xinu.at/dOLtod/ but I never managed to get the real count. I tried so many ways and…
    koffeingeladen
    • 325
    • 1
    • 2
    • 11
    15
    votes
    5 answers

    Jekyll post.content output is surrounded by

    tag

    When I print the content of the post with {{ post.content }} It is outputted like:

    Lorem ipsum...

    How can I remove the

    tag when generated. I need it to be removed before JavaScript starts to process the DOM.

    Ali Ismayilov
    • 5,727
    • 2
    • 22
    • 24
    15
    votes
    2 answers

    Total number of posts?

    I'm trying to figure out how to display the total number of posts in a category (or all together). I envision something like below, but can't quite figure it out. Did I miss something from the docs? {% for post in site.categories.CAT %} ...do…
    user375566
    14
    votes
    3 answers

    How to pass a variable into a custom tag in Liquid?

    I have written a custom tag in liquid, and I'd like to pass a variable to it. Liquid tags will turn any parameter into a string. For example: {% nav page /some/url.html %} Where page is a variable. Is there a way to get Liquid to treat page as a…
    Seth Ladd
    • 112,095
    • 66
    • 196
    • 279
    14
    votes
    2 answers

    How to increment the counter inside a Liquid for loop?

    I am struggling to figure out how to increment the index variable within a for loop in Liquid/Jekyll. Currently, I have something along the lines of {% for i in (0..num_posts) %} {% if i < some_value %} do_thing {% else %} {%…
    dkrist
    • 149
    • 1
    • 1
    • 4