Is there a reason the pagination template's "slots" value isn't configurable?

The “slots” controls how many pagination pages you see displayed at once. For example < 1 2 3 > has a slots value of 3 and < 1 2 3 4 5 > has a slots value of 5.

The default pagination template hard codes {{- $slots := 5 }} or {{- $slots := 3 }} depending on if you’re using the terse option.

When you have 30+ pages of content, 5 is kind of low.

It’s easy enough to duplicate the content locally and hard code the slots value you want, but it would be nice if we could configure the slots in Hugo’s configuration since that value isn’t configurable, only the pagerSize is.

Is there a reason this isn’t configurable? Given how useful it would be to customize this, I’m wondering if it wasn’t configurable for a reason I’m not thinking of.

I know when it comes to mobile design, a large value would look questionable since the page labels would wrap to multiple lines but that could be fixed with CSS within a project.

I am sure you are talking about a specific theme here, not how paginations in general work. In my own theme I have also what you call a 5 slot setup, but that can/could be configured.

image

For mobile pages, you could hide the numbers and keep the arrows alone. Also, how often do people on your website use this navigation?

PS: Interesting, looking into my template I realize that I call this variable “slots” :wink:

They are talking about these (for default pagination template) —

  1. hugo/tpl/tplimpl/embedded/templates/pagination.html at master · gohugoio/hugo · GitHub
  2. hugo/tpl/tplimpl/embedded/templates/pagination.html at master · gohugoio/hugo · GitHub

Yep, my question is related to the default paginator with Go, it’s unrelated to a theme.

Maybe something like {{- $slots := site.Params.pagination.slots | default 5 }}. This would also negate the need for the terse option.

There’s some history here…
https://github.com/gohugoio/hugo/pull/8602#issuecomment-855415586

I am not in favor of modifying the embedded pagination partial at this time given (a) the lack of demand and (b) the fact that it’s trivial to override.

If at some point we change the embedded pagination partial, we would add parameters to be passed in context. Tying embedded partials and shortcodes to site configuration gets messy.

1 Like