Support subfolder colocation for sections

Currently if I have a section (root section or otherwise) like so:

content
├── _index.md
├── file1.svg
└── mysubfolder
    └── file2.svg

And I check which assets are included in that section with the following code:

{% for asset in section.assets %}
<li>{{ asset }}</li>
{% endfor %}

It produces the following:

  • file1.svg

But I expect it to produce:

  • file1.svg
  • mysubfolder/file2.svg

Is there anything preventing adding this behaviour?

I think this behaviour is what most people would expect given that Zola already supports asset colocation subfolders for pages. It would be more consistent if they were also supported for sections.

Yes it’s a feature we want but is tricky to decide how it should look like. It’s definitely going to be added later though.

1 Like

Glad to hear it, thanks for the response. Is there another thread somewhere that I can read up on the discussion?

I imagine the problem is the logic which decides whether a folder is a page, section or just a folder of colocated assets?

I image that would be pretty easy, though. A folder with a section has a _index.md file, a page folder has an index.md file (without the underscore), and a folder with just assets has neither.

How do you differentiate it from a subsection?

I am confused – are you able to provide an example of a folder structure that would be ambiguous @keats? I am sure it would be obvious once pointed out but I’m struggling to wrap my head around this.

content (root section which contains home)
├── _index.md
├── file1.svg
└── foo
    └── file2.svg
    └── bar (treated as page)
        └── index.md
        └── baz (subfolder of assets because pages cannot contain sections)
    └── qux
        └── my_orphan_post.md
    └── fruits (section)
        └── _index.md
        └── banana (page)
            └── index.md
        └── citrus (subsection)
            └── _index.md
        └── pictures (asset folder)
            └── img1.jpeg