Skip to content

mushishi78/jekyll-group-by-array

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

Jekyll Group-By-Array

A liquid include file for Jekyll that allows an object to be grouped by an array. For instance, it could be used to list posts by tag.

Usage

Copy the group-by-array.html file into your Jekyll project's _includes directory.

Include the file in your template, passing in a collection and a field variable. Then Jekyll Group-By-Array will set group-names and group-items global variables with the results.

For example:

---
layout: page
title: Tags
permalink: /tags/
---

{% include group-by-array.html collection=site.posts field='tags' %}

<ul>
  {% for tag in group_names %}
    {% assign posts = group_items[forloop.index0] %}

    <li>
      <h2>{{ tag }}</h2>
      <ul>
        {% for post in posts %}
        <li>
          <a href='{{ site.baseurl }}{{ post.url }}'>{{ post.title }}</a>
        </li>
        {% endfor %}
      </ul>
    </li>
  {% endfor %}
</ul>

For an extended example, checkout out this group-by-array example branch of the Fresh Jekyll repository.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

A liquid include file for Jekyll for grouping by an array

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages