Hello,
I require some assistance please. I have updated my hugo version and my theme and broke pagination. My webdev knowledge is limited, but I have tried multiple things before deciding to write this post. I will try to describe everything to the best of my ability.
- Problem site example: Devblogs :: Iancu Makes Games Alone — Indie Games and Stories
- Theme in use: GitHub - panr/hugo-theme-hello-friend: Pretty basic theme for Hugo that covers all of the essentials. All you have to do is start typing!
- Hugo version:
Hugo Static Site Generator v0.80.0-792EF0F4 windows/amd64 BuildDate: 2020-12-31T13:37:57Z
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.15.1"
- Problem description: in my
config.toml
, I havepaginate = 5
, so I would expect that whenever I go to the Devblog section (I got 9 posts in it) (or click on a tag, or go to another section that has more than 5 posts), hugo would generate a list of 5 posts with a button at the bottom and if I click that button it takes me to the next page where I find the remaining 4 posts. Current behaviour - I get a list of 9 posts with the button at the end, and if I click that button I get the same list (but reloaded).
The only place where I found something about pagination is in .../themes/hello-friend/layouts/_default/index.html
:
{{ define "main" }}
{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }}
{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }}
{{ $PageContext := . }}
{{ if .IsHome }}
{{ $PageContext = .Site }}
{{ end }}
{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }}
...
One more thing I should mention is that none of my blog-type sections are defined as “posts”. In my config.toml
, I have:
...
[params]
# dir name of your blog content (default is `content/posts`)
contentTypeName = "devblog"
contentTypeNameType2 = "games"
contentTypeNameType3 = "stories"
...
That being said, going back to the index, I understand the code like so:
- if
contentTypeName
param is not “posts” or empty, define local variable $contentTypeName with value “posts” - this is my case, since I don’t use “posts”, but “devlog” for the param
contentTypeName
- next it assesses the page context, and since this is not the homepage,
$PageContext = .
- finally, we have
$paginator := .Paginate (where .RegularPages "Type" "posts")
I copied the index.html
file in my /site/layouts/_defaults/index.html
and tried to change different things, like removing all the logic and leaving just
{{ define "main" }}
{{ $paginator := .Paginate (where .RegularPages "Type" "devblog") }}
and then different variations:
{{ $paginator := .Paginate (where .Site.RegularPages "Type" "devblog") }}
{{ $paginator := .Paginate (where .Pages "Type" "devblog") }}
…
but am always getting the same result.
Any help would be appreciated.
Best regards,
Iancu