How to handle URL path traversal on slugs?

I’m wondering if it’s possible to force Hugo to generate intermediary index.html files for every part of my /posts/:year/:month/:slug for posts?

Like my ultimate goal is to either redirect the user to my archives page, or serve the archives from something like /posts/2018/index.html, /posts/2018/April/index.html, etc.

If i’m understanding your question, could you add aliases to each post for the old url?

Thanks for your response. I’ve realized I was asking the wrong question and have figured out my issue, but do have a related question to my original issue.

Based on my config of: /posts/:year/:slug
and given the posts layout of:

content/
| - posts/
    | - _index.md
    | - 2019/
    | - _index.md
        | - some-post/
            | - index.md

This generates:

posts/
| - index.html
| - 2019/
    | - index.html
    | - some-post/
        | - index.html

The question is, how can I turn the generated output of 2019/index.html to be a paginator for only posts that live beneath it (ie content within the 2019 directory)? For example /posts/ should be a paginator for all posts (which it correctly is), but /posts/2019/ should be a paginator for only 2019.

As of right now that 2019/_index.md is using the layouts/posts/list.html template, but I’d like it to be context aware we’re in 2019.

Am not sure on this one. My guess would be in your list template to filter down the pages you select to only those of the given year. But since you’ll have multiple sections/years, you’ll need a way to dyamically get the year. Hopefully others on here will be able to help you.

In the meantime, share your code, and you’ll be more likely to get help.

Sure, this is the logic I use now in posts/list.html to create a paginator for posts:

{{ $allPosts := (where (where .Site.Pages "Section" "posts") "Kind" "==" "page") }}
{{ $paginator := .Paginate $allPosts }}

Nope! :slight_smile:

You can search the forums, a lot of attempts and neat template tricks to get most of the way, but currently we don’t create blog-style date-based paginated archive pages.

But we might “soon”.