Group by section with custom ordering

How do I use a custom odering for sections defined in the front matter of the files? of the different sections is as follows:

title: "Posts"
ordering: 1

I list all pages on the homepage and group by section, but I want a custom section order not defined by the section key

{{ range .Data.Pages.GroupBy "Section" }}
	<h3>{{ ($.Site.GetPage "section" .Key).Title }}</h3>
		{{ range .Pages }}
				<a href="{{ .Permalink }}">{{ .Title }}</a>
		{{ end }}
{{ end }}

So how do I order the section by the ordering parameter in the

Perhaps this example helps:

{{ range .Data.Pages.GroupByParam "chapter" }}
    {{ range sort .Pages "summary" }}
        {{ .Title }}
    {{ end }}
{{ end }}

I tried that but it does not find the Parameter.

ERROR 2017/11/15 12:13:19 Error while rendering "home": template: theme/index.html:6:15: executing "theme/index.html" at <.Data.Pages.GroupByP...>: error calling GroupByParam: There is no such a param

Oh, sorry, .GroupByParam is just an example. Did you try it with your {{ range .Data.Pages.GroupBy "Section" }}?

Yeah, that works. But the question is how do I sort the groups by a custom param?

There are several examples on the sort function doc. In case sort wasn’t making sense in Leo’s example.

This does not throw an error

range sort (.Data.Pages.GroupBy "Section") .Params.ordering

But the param value has no influence on the sorting…

I can see that .Data.Pages does not even contain an ordering Param. Remember, I wanted to put it into the of the different archetypes

I can do this easily if I put the section order number into the archetype of each post type. But I would not like to repeat it and instead just put it into the of each content subdirectory. Is that not a good idea?

I also tried to add the order numer from the into the .Site.Pages array by doing something like this, but I could not get it to work:

range apply .Site.Pages "union" "." "($.Site.GetPage "section" .Type).Params.ordering" 

In this way I wanted to add the ordering number to each page.

Any ideas on how to to this?

A post was split to a new topic: How to sort by filename