Skip to content

Instantly share code, notes, and snippets.

Avatar
😏
:godmode:

Ricardo ricardoaat

😏
:godmode:
View GitHub Profile
@budparr
budparr / jekyll-group_by-example.liquid
Last active Jan 28, 2021
Example Jekyll group_by filter #jekyllrb
View jekyll-group_by-example.liquid
{% comment %}
items is a collection, though I think it coule be any content type
{% endcomment %}
{% comment %} Create the group. {% endcomment %}
{% assign items_grouped = site.items | group_by: 'category' | sort: 'name' | reverse %}
{% comment %}
The above returns, for example, which is why we sort by 'name'
{"name"=>"category1_value", "items"=>[#, #, #, #, #]}{"name"=>"category2_value", "items"=>[#, #, #, #]}
{% endcomment %}