Using paginator on a page with a specific URL


#1

I want to serve a page on a specific URL and I want to use a paginator on the page. For example the URL of the page would be simply “/series” and it would use a paginator to display content, so the URL could be “/series/page/[num]”. Now, I could simply create a new content page and assign the “series” URL to it, but unfortunately content pages cannot have paginators.

My question is, is there any way or at least workaround to achive the above described behavior?


#2

I would create a section series with just the _index.md inside it – then build a Paginator in the section template.


#3

Just tried it, but it still doesn’t work. So I have Hugo 0.18.1 and I have created an _index.md file under content/series (content/series/_index.md). The content of the _index.md file is the following:

--- title: "Series" layout: "series" ---

And I have also created a series.html named template file in the theme directory under layouts/series (layouts/series/series.html). I have also tried to remove the layout attribute from the _index.md file but still nothing. Even tried to restart the server and clear the browser cache but it didn’t help.


#4

You need to look at the template lookup documentation for Sections. I have been through this discussion in details just recently in this forum, and I’m not going there again.


#5

My fault, sorry. So section specific templates lie under the layouts/section directory. And the paginator works fine in the section’s template, so my problem is solved.

Just one more thing. I tired and I put some content file into the content/series directory, so now they can be reached on the “series/content-file-name” URL which is fine, but in the same time I also have a paginator for the series section so the “series/page/1”, “series/page/2”, etc URLs are also valid. It seems that both the pager and the individual content pages can be reached fine, but I guess if I would have a “page” named sub-directory with some content file in content/series that would broke the system. But until that, this should work fine I guess.