<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>branch on
A Scripter's Notes</title><link>https://scripter.co/tags/branch/</link><description>Recent content in branch
on A Scripter's Notes</description><language>en-us</language><managingEditor>kaushal.modi@gmail.com (Kaushal Modi)</managingEditor><webMaster>kaushal.modi@gmail.com (Kaushal Modi)</webMaster><lastBuildDate>Wed, 22 Apr 2026 08:24:58 -0400</lastBuildDate><generator>Hugo -- gohugo.io</generator><docs>https://validator.w3.org/feed/docs/rss2.html</docs><atom:link href="https://scripter.co/tags/branch/index.xml" rel="self" type="application/rss+xml"/><item><title>Hugo: Leaf and Branch Bundles</title><link>https://scripter.co/hugo-leaf-and-branch-bundles/</link><description>&lt;blockquote>Content organization for Hugo posts/articles using &lt;em>Page Bundles&lt;/em>.&lt;/blockquote>&lt;div class="ox-hugo-toc toc">
&lt;div class="heading">Table of Contents&lt;/div>
&lt;ul>
&lt;li>&lt;a href="#quick-summary">Quick Summary&lt;/a>&lt;/li>
&lt;li>&lt;a href="#leaf-bundle">Leaf Bundle&lt;/a>
&lt;ul>
&lt;li>&lt;a href="#examples-of-leaf-bundle-organization">Examples of Leaf Bundle organization&lt;/a>&lt;/li>
&lt;li>&lt;a href="#headless-bundle">Headless Bundle&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;a href="#branch-bundle">Branch Bundle&lt;/a>
&lt;ul>
&lt;li>&lt;a href="#examples-of-branch-bundle-organization">Examples of Branch Bundle organization&lt;/a>&lt;/li>
&lt;li>&lt;a href="#branch-bundle-vs-regular-sections">Branch Bundle vs Regular Sections&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;a href="#so-which-bundle-should-i-use">So, which bundle should I use?&lt;/a>&lt;/li>
&lt;li>&lt;a href="#upgrading-to-hugo-v0-dot-32">Upgrading to Hugo v0.32?&lt;/a>&lt;/li>
&lt;li>&lt;a href="#examples">Examples&lt;/a>&lt;/li>
&lt;li>&lt;a href="#further-reading">Further Reading&lt;/a>&lt;/li>
&lt;/ul>
&lt;/div>
&lt;!--endtoc-->
&lt;p>Hugo v0.32 introduced a new feature called &lt;strong>Page Bundles&lt;/strong> (&lt;a href="https://gohugo.io/content-management/organization/#page-bundles">1&lt;/a>, &lt;a href="https://gohugo.io/news/0.32-relnotes/">2&lt;/a>), as a
way to organize the content files. It is useful for cases where a page
or section&amp;rsquo;s content needs to be split into multiple content pages for
convenience, or has associated attachments like documents or images.&lt;/p>
&lt;p>A Page Bundle can be one of two types:&lt;/p>
&lt;ul>
&lt;li>Leaf 🍃 Bundle&lt;/li>
&lt;li>Branch 🌿 Bundle&lt;/li>
&lt;/ul>
&lt;div class="note">
&lt;p>The &lt;em>leaf&lt;/em> and &lt;em>branch&lt;/em> &lt;em>nodes&lt;/em> from &lt;a href="https://en.wikipedia.org/wiki/Tree_(data_structure)">Data Structure &lt;em>Trees&lt;/em>&lt;/a> serve as a
great analogy to help relate with the Hugo &lt;em>bundles&lt;/em>.&lt;/p>
&lt;blockquote>
&lt;dl>
&lt;dt>Leaf&lt;/dt>
&lt;dd>A node with no children.&lt;/dd>
&lt;dt>Branch&lt;/dt>
&lt;dd>A node with at least one child.&lt;/dd>
&lt;/dl>
&lt;/blockquote>
&lt;/div>
&lt;h2 id="quick-summary">Quick Summary&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#quick-summary">#&lt;/a>&lt;/h2>
&lt;p>Here&amp;rsquo;s a quick summary of the differences between these bundle types &amp;mdash;
Details follow in the sections after.&lt;/p>
&lt;p>&lt;a id="table--leaf-vs-branch">&lt;/a>&lt;/p>
&lt;div class="table-caption">
&lt;span class="table-number">&lt;a href="#table--leaf-vs-branch">Table 1&lt;/a>:&lt;/span>
Leaf Bundle vs Branch Bundle
&lt;/div>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;/th>
&lt;th>Leaf Bundle&lt;/th>
&lt;th>Branch Bundle&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Usage&lt;/td>
&lt;td>Collection of content and attachments for single pages&lt;/td>
&lt;td>Collection of attachments for section pages (home page, sections, &lt;code>taxonomy&lt;/code> list pages, &lt;code>term&lt;/code> list pages)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Index file name&lt;/td>
&lt;td>&lt;code>index.md&lt;/code> &lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup>&lt;/td>
&lt;td>&lt;code>_index.md&lt;/code> &lt;sup id="fnref1:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Allowed Resources&lt;/td>
&lt;td>Page and non-page (like images, pdf, etc) types&lt;/td>
&lt;td>Only non-page (like images, pdf, etc.) types&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Where can the Resources live?&lt;/td>
&lt;td>At any directory level within the leaf bundle directory.&lt;/td>
&lt;td>Only in the directory level &lt;strong>of&lt;/strong> the branch bundle directory i.e. the directory containing the &lt;code>_index.md&lt;/code> (&lt;a href="https://discourse.gohugo.io/t/question-about-content-folder-structure/11822/4?u=kaushalmodi">ref&lt;/a>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Layout type&lt;/td>
&lt;td>&lt;code>single&lt;/code>&lt;/td>
&lt;td>&lt;code>list&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Nesting&lt;/td>
&lt;td>Does not allow nesting of more bundles under it&lt;/td>
&lt;td>Allows nesting of leaf or branch bundles under it&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Example&lt;/td>
&lt;td>&lt;code>content/posts/my-post/index.md&lt;/code>&lt;/td>
&lt;td>&lt;code>content/posts/_index.md&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Content from non-index page files ..&lt;/td>
&lt;td>Accessed only as page resources&lt;/td>
&lt;td>Accessed only as regular pages&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;div class="note">
&lt;p>&lt;a href="https://github.com/gohugoio/hugo/releases/tag/v0.73.0">Hugo v0.73.0&lt;/a> made a much needed fix &amp;mdash; It finally renamed &lt;code>taxonomy&lt;/code>
Page Kind to &lt;code>term&lt;/code>, and &lt;code>taxonomyTerm&lt;/code> to &lt;code>taxonomy&lt;/code>. Now if you have
a &lt;code>tags = [&amp;quot;abc&amp;quot;]&lt;/code> front-matter, &lt;em>tags&lt;/em> is the &lt;strong>taxonomy&lt;/strong> and &lt;em>abc&lt;/em> is
a &lt;strong>term&lt;/strong>.&lt;/p>
&lt;/div>
&lt;h2 id="leaf-bundle">Leaf Bundle&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#leaf-bundle">#&lt;/a>&lt;/h2>
&lt;p>A &lt;em>Leaf Bundle&lt;/em> is a directory at any hierarchy within the &lt;code>content/&lt;/code>
directory, that contains an &lt;strong>&lt;code>index.md&lt;/code>&lt;/strong> file.&lt;/p>
&lt;h3 id="examples-of-leaf-bundle-organization">Examples of Leaf Bundle organization&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#examples-of-leaf-bundle-organization">#&lt;/a>&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">content/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── about
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ └── index.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── posts
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ ├── my-post
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ │ ├── content1.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ │ ├── content2.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ │ ├── image1.jpg
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ │ ├── image2.png
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ │ └── index.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│ └── my-another-post
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│    └── index.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">└── another-section
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> ├── ..
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    └── not-a-leaf-bundle
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> ├── ..
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    └── another-leaf-bundle
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    └── index.md
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In the above example &lt;code>content/&lt;/code> directory, there are four leaf
bundles:&lt;/p>
&lt;dl>
&lt;dt>about&lt;/dt>
&lt;dd>This leaf bundle is at the root level (directly under
&lt;code>content&lt;/code> directory) and has only the &lt;code>index.md&lt;/code>.&lt;/dd>
&lt;dt>my-post&lt;/dt>
&lt;dd>This leaf bundle has the &lt;code>index.md&lt;/code>, two other content
Markdown files and two image files. The content from the
two non-index &lt;code>.md&lt;/code> files can be accessed &lt;strong>only as page
resources, not as regular files&lt;/strong> i.e. those non-index
&lt;code>.md&lt;/code> files will not have their own permalinks or HTML
files in &lt;code>public/&lt;/code>.&lt;/dd>
&lt;dt>my-another-post&lt;/dt>
&lt;dd>This leaf bundle has only the &lt;code>index.md&lt;/code>.&lt;/dd>
&lt;dt>another-leaf-bundle&lt;/dt>
&lt;dd>This leaf bundle is nested under couple of
directories. This bundle also has only the &lt;code>index.md&lt;/code>.&lt;/dd>
&lt;/dl>
&lt;div class="note">
&lt;p>The hierarchy depth at which a leaf bundle is created does not matter,
as long as it is not inside another &lt;strong>leaf&lt;/strong> bundle.&lt;/p>
&lt;/div>
&lt;h3 id="headless-bundle">Headless Bundle&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#headless-bundle">#&lt;/a>&lt;/h3>
&lt;p>A headless bundle is a bundle that is configured to &lt;strong>not&lt;/strong> get
published anywhere:&lt;/p>
&lt;ul>
&lt;li>It will have no &lt;code>Permalink&lt;/code> and no rendered HTML in &lt;code>public/&lt;/code>.&lt;/li>
&lt;li>It will not be part of &lt;code>site.RegularPages&lt;/code>, etc.&lt;/li>
&lt;/ul>
&lt;p>But you can get it by &lt;code>site.GetPage&lt;/code>. Here is an example:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-go-html-template" data-lang="go-html-template">&lt;span class="line">&lt;span class="cl">&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$headless&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">:=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">site&lt;/span>&lt;span class="na">.GetPage&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;page&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;some-headless-bundle&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$reusablePages&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">:=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$headless&lt;/span>&lt;span class="na">.Resources.Match&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;author*&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">h2&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Authors&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">h2&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">range&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">$reusablePages&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">h3&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.Title&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">h3&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.Content&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">end&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>A leaf bundle can be made headless by adding below in the Front Matter
(in the &lt;code>index.md&lt;/code>):&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-toml" data-lang="toml">&lt;span class="line">&lt;span class="cl">&lt;span class="nx">headless&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="kc">true&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="note">
&lt;p>Only leaf bundles can be made headless.&lt;/p>
&lt;/div>
&lt;p>Example uses of headless page bundles:&lt;/p>
&lt;ul>
&lt;li>Shared media galleries&lt;/li>
&lt;li>Reusable page content &amp;ldquo;snippets&amp;rdquo;&lt;/li>
&lt;/ul>
&lt;h2 id="branch-bundle">Branch Bundle&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#branch-bundle">#&lt;/a>&lt;/h2>
&lt;p>A &lt;em>Branch Bundle&lt;/em> is a directory at any hierarchy within the
&lt;code>content/&lt;/code> directory, that contains an &lt;strong>&lt;code>_index.md&lt;/code>&lt;/strong> file. This
&lt;code>_index.md&lt;/code> can also be directly under the &lt;code>content/&lt;/code> directory, to
set the Home page content and/or front-matter variables.&lt;/p>
&lt;p>By default, Hugo considers the &lt;strong>first directory level&lt;/strong> under
&lt;code>content/&lt;/code> as a &lt;strong>section&lt;/strong>. But a branch bundle can be used to create a
&lt;em>section&lt;/em> at any hierarchy.&lt;/p>
&lt;h3 id="examples-of-branch-bundle-organization">Examples of Branch Bundle organization&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#examples-of-branch-bundle-organization">#&lt;/a>&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">content/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── _index.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── branch-bundle-2
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│   ├── branch-content1.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│   ├── branch-content2.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│   ├── image1.jpg
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│   ├── image2.png
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">│   └── _index.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">└── branch-bundle-3
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> ├── _index.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> └── a-leaf-bundle
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> └── index.md
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In the above example &lt;code>content/&lt;/code> directory, there are three branch
bundles (and a leaf bundle):&lt;/p>
&lt;dl>
&lt;dt>Home page as branch bundle&lt;/dt>
&lt;dd>The home page content is organized as a
branch bundle, using &lt;code>_index.md&lt;/code> directly in the &lt;code>content/&lt;/code>
directory. It consists of two other branch bundles.&lt;/dd>
&lt;dt>&lt;code>branch-bundle-2&lt;/code>&lt;/dt>
&lt;dd>This branch bundle has the &lt;code>_index.md&lt;/code>, two
other content Markdown files and two image files. The content
from the two non-index &lt;code>.md&lt;/code> files can be accessed &lt;strong>only as
regular pages, not as page resources&lt;/strong>. Branch bundles cannot have
page resources, so any non-index Hugo recognized content file in
a branch bundle can be accessed like any regular page (just like
in any section.. as.. a &lt;em>branch bundle&lt;/em> &lt;strong>is&lt;/strong> a &lt;em>section&lt;/em> too).&lt;/dd>
&lt;dt>&lt;code>branch-bundle-3&lt;/code>&lt;/dt>
&lt;dd>This branch bundle has the &lt;code>_index.md&lt;/code> and a
nested leaf bundle.&lt;/dd>
&lt;/dl>
&lt;div class="note">
&lt;p>The hierarchy depth at which a branch bundle is created does not
matter.&lt;/p>
&lt;/div>
&lt;h3 id="branch-bundle-vs-regular-sections">Branch Bundle vs Regular Sections&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#branch-bundle-vs-regular-sections">#&lt;/a>&lt;/h3>
&lt;dl>
&lt;dt>Branch Bundle section&lt;/dt>
&lt;dd>Any directory in &lt;code>content/&lt;/code> that contains
the &lt;code>_index.md&lt;/code> file.&lt;/dd>
&lt;dt>Regular Section&lt;/dt>
&lt;dd>Any &lt;strong>first-level directory&lt;/strong> in &lt;code>content/&lt;/code>, and
also home page and &lt;code>taxonomy&lt;/code> list page .. that is &lt;strong>not&lt;/strong> already a
Branch Bundle.&lt;/dd>
&lt;/dl>
&lt;p>&lt;a id="table--branch-bundle-section-vs-regular-section">&lt;/a>&lt;/p>
&lt;div class="table-caption">
&lt;span class="table-number">&lt;a href="#table--branch-bundle-section-vs-regular-section">Table 2&lt;/a>:&lt;/span>
Branch Bundle section vs Regular section
&lt;/div>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;/th>
&lt;th>Branch Bundle Section&lt;/th>
&lt;th>Regular Section&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>.Kind&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;section&amp;quot;&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;section&amp;quot;&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>.File.Path&lt;/code>&lt;/td>
&lt;td>&lt;code>/path/to/_index.md&lt;/code>&lt;/td>
&lt;td>&lt;code>&amp;quot;&amp;quot;&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Layout type&lt;/td>
&lt;td>&lt;code>list&lt;/code>&lt;/td>
&lt;td>&lt;code>list&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Can contain non-page Resources?&lt;/td>
&lt;td>Yes&lt;/td>
&lt;td>No&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Can contain page Resources?&lt;/td>
&lt;td>No&lt;/td>
&lt;td>No&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;div class="note">
&lt;p>Branch Bundle is basically a Section with non-page Resources.&lt;/p>
&lt;/div>
&lt;p>Here&amp;rsquo;s an example snippet that can be used in a &lt;code>list&lt;/code> template to
distinguish between the two:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-go-html-template" data-lang="go-html-template">&lt;span class="line">&lt;span class="cl">&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">if&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">(&lt;/span>&lt;span class="k">eq&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.Kind&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;section&amp;#34;&lt;/span>&lt;span class="o">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span> &lt;span class="c">&amp;lt;!-- Section --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">if&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">(&lt;/span>&lt;span class="k">eq&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.File.Path&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;&amp;#34;&lt;/span>&lt;span class="o">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span> &lt;span class="c">&amp;lt;!-- Regular section --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">h1&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Posts in ‘&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.Dir&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">default&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.Section&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>’&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">h1&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">else&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span> &lt;span class="c">&amp;lt;!-- Branch bundle section --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">h1&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.Title&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">h1&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">h2&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Posts in ‘&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.Dir&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">default&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="na">.Section&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>’&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">h2&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">end&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">{{&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">end&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">}}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;h2 id="so-which-bundle-should-i-use">So, which bundle should I use?&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#so-which-bundle-should-i-use">#&lt;/a>&lt;/h2>
&lt;p>In summary:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>If it&amp;rsquo;s a &lt;em>regular&lt;/em> page or a &lt;em>single&lt;/em> page where you write your
content &lt;strong>yourself&lt;/strong>, create a &lt;em>leaf bundle&lt;/em>.&lt;/p>
&lt;p>&lt;mark>Page Bundles of &lt;code>page&lt;/code> &lt;a href="https://gohugo.io/templates/section-templates/#page-kinds">&lt;em>Kind&lt;/em>&lt;/a> are always &lt;em>leaf bundles&lt;/em>.. and vice versa.&lt;/mark>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Otherwise, if it&amp;rsquo;s a &lt;em>list&lt;/em> page which Hugo generates for you,
create a &lt;em>branch bundle&lt;/em>. Such pages typically are a list of
&lt;em>regular&lt;/em> pages or even other &lt;em>list&lt;/em> pages. Pages of &lt;code>home&lt;/code>,
&lt;code>section&lt;/code>, &lt;code>taxonomy&lt;/code> and &lt;code>term&lt;/code> &lt;em>Kind&lt;/em> are always &lt;em>branch bundles&lt;/em>.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>&lt;a id="figure--bundle-decision">&lt;/a>&lt;/p>
&lt;figure>
&lt;img src="https://scripter.co/hugo-leaf-and-branch-bundles/flowchart.svg" alt="Figure 1: Do I need a leaf bundle, or branch bundle, or none?"/> &lt;figcaption>
&lt;p>
&lt;span class="figure-number">Figure 1: &lt;/span>Do I need a leaf bundle, or branch bundle, or none?
&lt;/p>
&lt;/figcaption>&lt;/figure>
&lt;h2 id="upgrading-to-hugo-v0-dot-32">Upgrading to Hugo v0.32?&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#upgrading-to-hugo-v0-dot-32">#&lt;/a>&lt;/h2>
&lt;p>All of this boils down to these few caution points if you are
upgrading Hugo from a pre-0.32 version to 0.32 or a newer version:&lt;/p>
&lt;ul>
&lt;li>If a directory &lt;code>foo&lt;/code> has an &lt;code>index.md&lt;/code> (leaf bundle), that file will
be the content file for that &lt;code>foo&lt;/code> &lt;em>Regular&lt;/em> Page.&lt;/li>
&lt;li>If a directory &lt;code>foo&lt;/code> has an &lt;code>_index.md&lt;/code> (branch bundle), that file
will be the content file for that &lt;code>foo&lt;/code> &lt;em>Section&lt;/em> Page, and &lt;em>all
other&lt;/em>&lt;sup id="fnref:2">&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref">2&lt;/a>&lt;/sup> &lt;code>.md&lt;/code> files in the same or deeper hierarchy levels
under &lt;code>foo/&lt;/code> will become &lt;em>Regular&lt;/em> Pages under that &lt;code>foo&lt;/code> section.&lt;/li>
&lt;/ul>
&lt;h2 id="examples">Examples&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#examples">#&lt;/a>&lt;/h2>
&lt;p>Of course, a post like this is not complete without examples, so here
they are:&lt;/p>
&lt;p>&lt;a id="table--leaf-branch-bundle-examples">&lt;/a>&lt;/p>
&lt;div class="table-caption">
&lt;span class="table-number">&lt;a href="#table--leaf-branch-bundle-examples">Table 3&lt;/a>:&lt;/span>
Leaf and Branch bundle examples
&lt;/div>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Example&lt;/th>
&lt;th>Markdown source&lt;/th>
&lt;th>HTML output&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>This page&lt;/strong> (leaf bundle)&lt;/td>
&lt;td>&lt;a href="https://gitlab.com/kaushalmodi/kaushalmodi.gitlab.io/tree/master/content/posts/hugo-leaf-and-branch-bundles">&lt;code>content/posts/hugo-leaf-and-branch-bundles/&lt;/code>&lt;/a>&lt;/td>
&lt;td>&lt;em>duh!&lt;/em>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Leaf and branch bundle examples from &lt;code>ox-hugo&lt;/code> test site&lt;/td>
&lt;td>&lt;a href="https://github.com/kaushalmodi/ox-hugo/tree/master/test/site/content/bundles">&lt;code>content/bundles/&lt;/code>&lt;/a>&lt;/td>
&lt;td>&lt;a href="https://ox-hugo.scripter.co/test/bundles/">Bundles&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Headless (leaf) bundle example from the same&lt;/td>
&lt;td>&lt;a href="https://raw.githubusercontent.com/kaushalmodi/ox-hugo/master/test/site/content/posts/page-using-headless-page-bundle.md">content page using headless bundle&lt;/a> + &lt;a href="https://github.com/kaushalmodi/ox-hugo/blob/master/test/site/layouts/_default/headless-bundle-single.html">Layout fetching headless bundle pages&lt;/a>&lt;/td>
&lt;td>&lt;a href="https://ox-hugo.scripter.co/test/posts/page-using-headless-page-bundle">Page using the Headless Page Bundle&lt;/a>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Branch bundles used for &lt;code>home&lt;/code>, &lt;code>taxonomy&lt;/code>, and &lt;code>term&lt;/code> &lt;em>Kind&lt;/em> pages&lt;/td>
&lt;td>&lt;a href="https://gitlab.com/kaushalmodi/hugo-sandbox/tree/master/content">Hugo &lt;em>Sandbox&lt;/em> &lt;code>content/&lt;/code> dir&lt;/a>&lt;/td>
&lt;td>&lt;a href="https://hugo-sandbox.netlify.com/">Hugo Sandbox&lt;/a>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="further-reading">Further Reading&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#further-reading">#&lt;/a>&lt;/h2>
&lt;p>I suggest reading the below pages in the Hugo documentation, as they
complement the &lt;em>Page Bundles&lt;/em> concept:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://gohugo.io/content-management/organization/">Content Organization&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://gohugo.io/content-management/page-resources/">Page Resources&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://gohugo.io/content-management/image-processing/">Image Processing&lt;/a>&lt;/li>
&lt;/ul>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>The &lt;code>.md&lt;/code> extension for &lt;code>index.md&lt;/code>, &lt;code>_index.md&lt;/code>, and all other
content files in this post is just an example. The extension can be
&lt;code>.html&lt;/code> or any of any valid MIME type recognized by Hugo.&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&amp;#160;&lt;a href="#fnref1:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:2">
&lt;p>It&amp;rsquo;s a qualified &amp;ldquo;all other&amp;rdquo; &amp;mdash; That does not count the content
files further nested in leaf and branch bundles in that &lt;code>foo&lt;/code> section.&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></description><author>Kaushal.Modi@fakeEmailToMakeValidatorHappy.com (Kaushal Modi)</author><category domain="https://scripter.co/categories/hugo">hugo</category><category domain="https://scripter.co/tags/page-bundles">page-bundles</category><category domain="https://scripter.co/tags/leaf">leaf</category><category domain="https://scripter.co/tags/branch">branch</category><category domain="https://scripter.co/tags/flow-chart">flow-chart</category><guid>https://scripter.co/hugo-leaf-and-branch-bundles/</guid><pubDate>Tue, 06 Mar 2018 12:40:00 -0500</pubDate></item></channel></rss>