Generating multiple "list" pages with different sorting

How can I generate multiple “list” pages for all of my posts? I’d like to make separate list pages sorted by Title (ascending and descending), Lastmod date (ascending and descending) and content length (asc and desc). I’d like all of those list pages to link to each other. Think of an Apache mod_autoindex directory listing with sortable columns but statically generated. I’ve got a list page for one of those “sort” modes working but don’t know how to do it for the rest of them.

You’ll have to define a custom output format for each of your list page, except the one provided by Hugo of course.


Within the content directory you will need a stub for each list page, something like:

└── posts/
    ├── by-title-asc/
    │   └──
    └── by-title-desc/

Then create a unique layout for each list, something like:

├── posts-by-title-asc.html
└── posts-by-title-desc.html

Try it:

git clone --single-branch -b hugo-forum-topic-39670 hugo-forum-topic-39670
cd hugo-forum-topic-39670
hugo server

If you don’t like the brute force approach of creating a different layout for each view, you could parameterize a single template to use values from the front matter of each stub in the content directory.


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