Should transparant sections pass their subsections?

Hi!

I’m working on adding sorting and lower/higher fields to sections (@keats noted here that them being missing is a bug), and I stumbled upon one small inconsistency while writing tests.

Now sections can be “transparent”, which means that they reparent their pages to the ancestor section. But this doesn’t apply to subsections. So if we have something like:

content/_index.md
├─content/blog/_index.md            weight=0
├─content/novels/_index.md          weight=3
└─content/wiki/_index.md            weight=0 transparent=true
  ├─content/wiki/recipes/_index.md  weight=1
  └─content/wiki/dev/_index.md      weight=2

… the structure will be preserved, and transparent=true will kinda be ignored.

I would expect Zola to flatten the subsection list, so we would get:

content/_index.md
├─content/blog/_index.md            weight=0
├─content/wiki/recipes/_index.md    weight=1
├─content/wiki/dev/_index.md        weight=2
└─content/novels/_index.md          weight=3

Is this a bug, or is it supposed to work like this? Should I fix it?

1 Like

Hmm that’s a good question. I’m not entirely sure what should be the outcome since I didn’t think of transparent as something over sections. If we make that feature, I think it should be opt-in in some ways?

A real-life use case would be this one:
Imagine a user who prefers storing their posts organized by date. (e.g. content/2023/01/...).
In addition, they write an ongoing series of posts named learn_rust

content/
└─2023/          transparent=true
  └─01/          transparent=true
    ├─post1.md
    └─learn_rust/
      ├─day1.md
      └─day2.md

I would expect the end result to look like:

content/
├─post1.md
└─learn_rust/
  ├─day1.md
  └─day2.md

While currently only the posts “bubble up”:

content/
├─post1.md
└─2023/
  └─01/
    ├─post1.md
    └─learn_rust/
      ├─day1.md
      └─day2.md

To me, it seems more like a bug, tbh.
Here’s a toy project to test this.

1 Like