Suppose my paginator has 20 pages, and I want to show maximum 10 pages in it, then how to do it? I tried these codes in config file, but couldn’t make it work:
[languages.en.params]
paginate = true
disableAliases = true
pagerSize = 10
[languages.en.params]
[languages.en.pagination]
paginate = true
disableAliases = false
pagerSize = 10
[languages.en.params]
[pagination]
paginate = true
disableAliases = false
pagerSize = 10
irkode
July 19, 2024, 9:16pm
2
Accoding to the docs here Pagination | Hugo it should be:
[languages.en]
contentDir = 'content/en'
languageCode = 'en-US'
languageDirection = 'ltr'
languageName = 'English'
weight = 1
[languages.en.pagination]
disableAliases = true
pagerSize = 10
path = 'page'
There might be other pitfalls though, like double pagination per page… but if above does not help you’ll need to change your code
I think contentDir = ‘content/en’ is used if multi-lang content-structure is directory based.
Rest I tried already. I also added path = ‘page’
But, didn’t work.
Sry. Maybe I should write 20 pagers
This would be a lot easier to troubleshoot if you would share your project repository. Guessing isn’t very efficient for either of us.
Remove the paginate
setting from the root of your configuration:
https://github.com/r84iw6/mini/blob/95cc0caaff462c94c219df153dfd8c1430f87750/config.toml#L7
And make sure you are running v0.128.0 or later.
It didn’t work.
Hugo ver 0.129.0
I’m not sure what to tell you. It worked for me. As soon as I removed that setting the per-language settings worked as expected.
Thanks for your help.
But, I think it’ll take me time to get it working.
irkode
July 20, 2024, 5:09am
12
Hehe. Not really.
Actually my mistake in understanding pagerSize .
I just read in Hugo Docs that pagerSize setting is to control number of pages listed per pager.
So, it’s actually same setting per language as Paginate (global) that Mr jmooring asked me to remove.
It’s working fine.
What I actually want to do is to limit the number of page-numbers listed in paginator. I don’t want to display more than 10 page-numbers (1,2,3…,10) to be listed in paginator.
How to do it?
I’d just use the embedded pagination template.
In your home page template replace this:
{{ template "partials/paginator.html" . }}
With this:
{{ template "_internal/pagination.html" . }}
That will give you a maximum of 5 slots.
See https://gohugo.io/templates/pagination/#navigation .
Hi. I saw that “_internal/pagination.html” working in a theme. But, then I can’t modify its CSS. Right?
Why don’t you try it and see what happens?
As I told you I have already seen it working as I want. But, I can’t modify its CSS. That’s the problem with it.
fastguy:
I can’t modify its CSS
I don’t know what that means. It doesn’t have any CSS. You add CSS to your project to target specific elements, id’s, or classes.
I mean… I can’t modify its design/UI as I want. Because it’s a default internal code.