Proposal/Question: Transparent modes

I use sections a lot, and this is the main way of organizing posts for me. I use URL parts to display them in the navigation bar so that the user would know in which section they are.
However, on the index page (a.k.a. parent section) I’d like to show a list of the recent posts.

Currently, I can see two ways of achieving this:

Transparent mode

Set transparent=true in the configuration of each section.

This works just fine, but I’m not happy, since all the pages actually moved into the parent section. So, the URL of each page is different now, by default it points to the parent-section/post.html and parent-section/child-section/post.html just redirects to the former address.

I’d like to have it that other way around: pages belong to their “real” section and the parent just host redirects

Collecting pages manually

The other approach would be to go through all subsection in the parent page, collect posts and then sort them by date.

This produces even more problems than it solves. Fist of all, there might be a grand-section inside a child one, so this needs to be somehow recursive. Second, I’m using pagination and if one child section contains so many new posts that they become paginated, then posts from the second page won’t be in the resulting list.

Solution?

As a solution I can propose adding transparent_mode section configuration option, which can take values child or parent with the latest as default one. This will change the behavior of how pages are being passed to the parent.

In parent mode the behavior remains the same as it is now. Parent becomes the new “home” for the posts, which is reflected in the URL.

In child mode, the URL remains the same and the parent just gets the links.

Will this change make sense? Or do you folks think that this use case is too specific?

4 Likes

@keats, any thoughts on this? I can start working on an implementation.

I think this is too specific, let’s see if more people need it but I’m not too sold on that.

I’d like to have a section that just includes posts from two other sections. In my current CMS, which does not use a strict hierarchy, I basically have: /notes formed by a query “type is note”, /articles formed by a query “type is article”, /posts formed by a query “type is note OR article”. I’m interested in replicating that /posts in Zola.

Looks like having posts as a parent section with the other two being transparent child sections would be the easiest way. The two issues I’m seeing:

  • the child categories are not appearing in ancestors (and I really want to link to them in each post!)
  • the auto URLs (without setting an explicit path) actually turn out to be /posts/notes/X style (did something change since this thread was started? doesn’t sound like “parent mode” is the current behavior at all!)
    • but I actually want the URLs to be /notes/X i.e. a different kind of “transparent” — as if the parent section wasn’t there

So actually my use case is probably better served by some kind of include = ["/notes", "/articles"] in the _index.md of /posts that would… well, include all the posts from other particular categories.

1 Like

include syntax seems to be more general than transparent_mode which I originally suggested here, I really like it!

My use case could be supported by using wildcards, like include = [ "/*" ]. Even if wildcards will be too cumbersome to implement, just listing all the sections manually there shouldn’t be that much work.

I have an implementation now: Implement section include (WIP: docs, translation support?) · unrelentingtech/zola@7224ce8 · GitHub

1 Like