Skip to content

Instantly share code, notes, and snippets.

View ricardoaat's full-sized avatar
😏
Working from home

Ricardo ricardoaat

😏
Working from home
View GitHub Profile
@budparr
budparr / jekyll-group_by-example.liquid
Last active January 21, 2024 11:10
Example Jekyll group_by filter #jekyllrb
{% 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 %}