Advanced Grouping

I can’t find anything in the Hugo docs about the matter, so I decided bring this up.

I know the Hugo has the built in grouping stuff, but sometimes this is not enough.
Sometimes is necessary to group an array from a data file ("/data/somedatawithanarray.json"). It’s not nice have to iterate over an array to group it using the $.Scratch.

I believe a group command would by very straightforward. Something like:

$groups := group $somearray "someprop"

The expected result would by a dictionary containing a key and an array.

It could also be usefull to have a then by. The syntax could be something like:

$groupsofgroups := group $somearray "someprop" "anotherprop"

In this case, the expected result would by a dictionary containing a key and an array of dictionaries (groups).

Sorry if a similar feature already exists, but I couldn’t find it anywhere.

1 Like