making Hugo Homepage a post listing

Table of Contents

With a recent hugo upgrade on my machine, suddenly all my front-pages were links to my “posts” section and only one click later would you see what had correctly been my homepage previously. I received no help on Reddit or on the themes (which, some of which, unfortunately, are no longer maintained), so did some studying and got it back to working. Here is hoping this helps solve your issue.

Resources considered

https://gohugo.io/templates/lookup-order/ https://gohugo.io/templates/lists/ https://gohugo.io/templates/homepage/

Solution

The root index rendering is located under your hugo paths at layouts/index.html, in which you’ll search for the (where ...) section that will iterate through your posts.

It looks like .Data.Pages is no longer valid and needs to be changed to .Site.RegularPages, and "Section" becomes "Type".

In Binario, the old theme:

{{- $mainSections := .Site.Params.mainSections }}
{{- $paginator := .Paginate (where .Data.Pages "Section" "in" $mainSections) }}

And new, working with modern Hugo:

{{- $mainSections := .Site.Params.mainSections }}
{{- $paginator := .Paginate (where .Site.RegularPages "Type" "in" $mainSections) }}
Tory Anderson avatar
Tory Anderson
Web App Engineer, Digital Humanist, Researcher, Computer Psychologist