Branch Bundles and Leaf Bundles

Hi All,

I’ve been doing a lot of reading about resources and bundles, and was wondering when it would be a good time to use a branch bundle vs. when it would be good to use a leaf bundle.

I’ve read the Page Bundles document, but am looking for a bit more guidance on how I should use them.

I’m putting together a website for a theater company that will have members, associate members, and board members.

├── company/
    ├── sarah_jones/
    |   sarah_jones.jpg
    ├── ann_smith/
    |   ann_smith.jpg
    ├── gary_bepo/
    |   gary_bepo.jpg

In this case, the company/ would be a branch bundle, with individual leaf bundles under it for each company member / associate member / board member. I was thinking that this would be a good approach because each individual would only need their own directory with an index file and their bio picture.

The branch bundle would be a sort of summary page, and would use resources to reference the leaves’ images and some of the leaves’ content.

Within each person’s individual directory, their individual file would have metadata to indicate whether they were a member, associate member, or board member, and I could use that data in the templates.

Does this sound like a good approach?

Thanks in advance for any tips or advice.

The approach looks good in general, but I wanted to clarify this piece:

I don’t think that you can access the nested leaf bundles’ image resources directly from the branch bundle (I haven’t tried that, but it would be weird if that were possible). You would need to range through all the pages (leaf bundles) in that branch bundle, and then access the resources for each leaf bundle using their own context.

I hope that makes sense.

Thanks for the reply! With regards to this comment:

It sounds like I’d need to handle this via a template then, which I hope will be fine.

That’s correct. Explore the type and layout front matter. They come in very handy to set page-specific layouts.

1 Like

Your structure looks good but if I understood right, what you call leafs are actually posts/pages.

And you can range through them quite easily. I have a section called stories, and inside several different stories, each with its own chapters (posts).

I range through the chapters like this in the file taxonomy/story.html:

{{range (.Paginate ( where .Data.Pages "Type" "stories")  9).Pages}}
    {{ .Render "summary"}}
{{ end }}

And I show the story title from the file using frontmatter params.

{{ .Params.story_title }}

hope this helps

1 Like