Custom List Page

How do I make a custom list page at a custom location? How do I configure its paginator?

The issue is that I have multiple sections, and I want a global archive page at /archive/, while keeping my home page different at /. I’ve tried several appraoches:

  1. content/archive.html with type: list or layout: list
  2. layout/archive.html with {{ $paginator := .Paginate .Site.RegularPages }}

None of this seems to work. What is the recipe for setting for doing this?

See:

First you fetch what you need with .GetPage and then within its scope you can paginate the content etc.

EDIT
If this is for a global site archive another approach would be to use the mainSections method.

That doesn’t work, because it does not allow for pagination…

Right. As per the Documentation:

Hugo supports pagination for your homepage, section pages, and taxonomies.

Also there is no built-in functionality for archives.

I suppose that you could configure an archive taxonomy, assign it to your content files and try to paginate that.

content/archive/_index.md will give you a list page at yoursite.com/archive.

layouts/_default/archive.html , or some other location, see: Template lookup order | Hugo

That works.

Putting this in the template page (“layouts/archive.html”) uses the standard list template too:

{{ $paginator := .Paginate .Site.RegularPages }}
{{ .Render “list” }}

Of course, you can put any filters you’d like here without any difficulty.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.