Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8768723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:08:22+00:00 2026-06-13T17:08:22+00:00

I have a Jekyll app (using Liquid) and I’d like to know how to,

  • 0

I have a Jekyll app (using Liquid) and I’d like to know how to, in Liquid, group a collection of items into a small subset of collections.

For instance, pretend I have this array:

fruits = ['apples', 'oranges', 'bananas', 'pears', 'grapes']

What I’d really like to do, in the Liquid page, is get this:

fruit_groups = [['apples', 'oranges'], ['bananas', 'pears'], ['grapes', null]]

For example, Ruby on Rails can do this with their .group_by method attached to enumerables.

Can I do this in Liquid?

Use case: I have a big collection of items, but I need to convert them into columns of <ul> elements. So, if I have three columns, I need to get three sub-collections.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:08:24+00:00Added an answer on June 13, 2026 at 5:08 pm

    This doesn’t answer your question directly, but I’m not sure that you’d want to do what you’re describing (and I’m pretty sure you can’t) – Liquid is a templating system, not a fully fledged programming language. I suspect that you’ll be able to achieve your end goal using some of the for loop and cycle features: http://code.google.com/p/liquid-markup/wiki/UsingLiquidTemplates

    eg:

    <ul>
    {% for fruit in fruits %}
        {% capture pattern %}{% cycle 'odd_class', 'even_class' %}{% endcapture %}
            <li class={{ pattern }}>{{ fruit }}</li>
    {% endfor %}
    </ul>
    

    or

    <ul class="odd">
    {% for fruit in fruits %}
        {% capture pattern %}{% cycle 'odd', 'even' %}{% endcapture %}
        {% if pattern == 'odd' %}
            <li>{{ fruit }}</li>
        {% endif%}
    {% endfor %}
    </ul>
    
    <ul class="even">
    {% for item in fruits %}
        {% capture pattern %}{% cycle 'odd', 'even' %}{% endcapture %}
        {% if pattern == 'even' %}
            <li>{{ fruit }}</li>
        {% endif%}
    {% endfor %}
    </ul>
    

    If you have three columns, you’d just have three steps in your cycle, and three directions to go in your if statement.

    If all that fails, you could write a plugin (in Ruby) that will restructure your data before it ever hits the template layer, but I suspect that would be overkill.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a for loop in Liquid (using Jekyll), how can I target
I have a Jekyll (Liquid) block plugin and I'd like to detect what the
It seems like syntax highlighting in Jekyll is limited to using liquid tags and
I have a custom page for Jekyll: I have a news.markdown file like the
I'm using Jekyll to create a new blog. It uses Liquid underneath. Jekyll defines
I'm writing a site in Jekyll, which uses Liquid. I have front matter for
Have my app up on Heroku. Using rack-canonical-host to handle re-directs from myapp.heroku.com to
I have this custom made site using Jekyll: http://madhur.github.com/ When I view this site
I have to parse YAML Front Matter in java like jekyll , So Iooked
I am new using Jekyll and Jekyll-Bootstrap. I have found this for filtering by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.