Faux Pagination

I’ve been out of the Hugo loop for a bit, but it looks like Pagination is not a thing yet? Is there any known hack for the time being. It can be as dirty as Wordpress is provided it works. I only have about 20 posts, and I just want to show a count 1/20, 2/20 on the single template pages.

Can I return the number of published posts to the single template? That would be half the solution, and I could just add a custom front matter with manual pagination numbers for now.

See:

What you talk about MAY be possible, but I would just wait, it’s coming, very soon.

Thanks. I’ve set a manual totalPostCount in config.toml for the time being, and am manually adding a postNumber in each posts’ front matter, but I through there might be a better workaround than this.

{{ if .Params.postNumber }}
  <strong>{{ .Params.postNumber }}</strong>/{{ .Site.Params.totalPostCount }}
{{ end }}

You can do better than that.

This is some stats I show on my site (in Norwegian):

https://github.com/bjornerik/bepsays.com/blob/master/layouts/about/single.ace

{{ len .Site.Pages }}

Should give you the current page count. The len function can be used to count a number of things.

You should be able to get a postNumber too by doing some magic mumbu jumbo …

But as I said, I would wait.

1 Like

Thanks for the tips. I’ll look into {{ len .Site.Pages }}.