_index folder for bundling in branches

Hello there,

Regarding branches page resources i see we have to put resources files at the same level than “_index”.

I understand why it’s like that, but having the option to create a folder strictly named “_index”, containing an “index” and all its resources in subfolders, like a leaf, but compiled as the branch it is, would be great for maintaining a tidy folder arborescence, as it can be a mess when those list type branch pages get loaded with resources.

This could be optional and we get to keep the flat _index files working as it is, but we could jump on a folder structure when needed.

Maybe that’s not useful in your eyes, or impractical to implement, i just wanted to share the idea, as i feel it could be a good one. I will gladly hear what you think about it.

Thanks for reading :slightly_smiling_face:

This becomes a real problem with partials, i have a lot of partials designed to fetch data following a directory structure, like a gallery partial looking in the subfolder “gallery” of its page context :

{{ with $.ctx.Resources.GetMatch (printf "gallery/%s*" .img) }}
   {{ partial "gallery" (dict "img" . "alt" "") }}
{{ end }}

This whole partial library becomes obsolete only in that case, that’s really unfortunate.

I agree about the conclusion. I have a development branch that’s reimplementing the tree structure that stores and navigates all of this. I’ll admit that I haven’t solved your particular issue in that branch (yet), but your suggestion might be a OK compromise.

But I think this would be for resources only, so it would look like:

content
└── posts
    ├── _index.md
    └── _resources
        └── image.png

The above could work for all bundles, for people liking symmetry…

2 Likes

I’ve managed to rewrite these partials with this kind of conditional :

{{ if (or $.ctx.IsSection $.ctx.IsHome) }}
  ...fetch resources located within the same directory
{{ else }}
  ...fetch resources located within subfolders
{{ end }}

If find that acceptable.

ps: .ctx is the page context of the partial passed with a dict

{{ partial "gallery" (dict "ctx" . "data" .Params.gallery) }}

This looks great to me, as long as we can go through multiple subfolders like this :

content
└── posts
    ├── _index.md
    └── _resources
        └── gallery-for-my-partial
            └── image.png
        └── pdfs-for-my-other-partial
            └── file.pdf

I would then change my pages bundles to :

content
└── posts
    ├── _index.md
    └── post1
        └── _resources
        |   └── gallery
        |       └── image.png
        └── index.md

This would keep my partials without any conditionals (like shown in the previous reply above) and would be beautiful

Yep…

Feel free to close the topic, knowing that you have a dev branch implementing a solution to that is more than enough to me, sweet lord thank you so much :smiling_face_with_three_hearts:

1 Like

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