[SOLVED] How do I show different types on homepage separately?


#1

My site will have several sections, each of which has its own “type”. For this question, let’s say they are “projects” and “notes”. (In my content folder there will be a folder called “projects” and another called “notes”, inside of which each has content files.)

On the homepage I’d like to display the five most recent projects and then the most recent note. I don’t want them to be mixed in a .Data.Pages kind of way.

This seems like it should be reasonably simple, but for the life of me I can’t figure this out. Any help would be greatly appreciated!


#2

Aha, got it! (found answer here: https://github.com/gohugoio/hugo/pull/413)

The basic thing to grab each section looks like this:

{{range first 5 (where .Data.Pages "Section" "projects") }}
  {{ .Title }}
{{ end }}