Is there a way to order pages explicitly?

Because I need to change the order of my pages very often.
I almost have to modify the weight params for each post everty time.
I want to have a specific file which I can define the order of my pages in that file. And when I need to change the order I only have to swap lines in that file.

data/collections.yaml

foo:
  - posts/post-2.md
  - posts/post-1.md
  - posts/post-3.md
bar:
  - posts/post-5.md
  - posts/post-4.md
  - posts/post-6.md

template

{{ range site.Data.collections.foo }}
  {{ with site.GetPage . }}
    <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
  {{ else }}
    {{ errorf "Unable to get page %s" . }}
  {{ end }}
{{ end }}

This won’t scale well, but for a site with a few hundred pages performance should be acceptable.

1 Like