Debian Codegraph @

docs/content/en/content-management/page-bundles.md

raw
1 ---
2 title: Page bundles
3 description: Use page bundles to logically associate one or more resources with content.
4 categories: []
5 keywords: []
6 ---
7
8 ## Introduction
9
10 A page bundle is a directory that encapsulates both content and associated resources.
11
12 By way of example, this site has an `about` page and a `privacy` page:
13
14 ```tree
15 content/
16 ├── about/
17 │ ├── index.md
18 │ └── welcome.jpg
19 └── privacy.md
20 ```
21
22 The `about` page is a page bundle. It logically associates a resource with content by bundling them together. Resources within a page bundle are [page resources][], accessible with the [`Resources`][] method on the `Page` object.
23
24 Page bundles are either _leaf bundles_ or _branch bundles_.
25
26 leaf bundle
27 : A _leaf bundle_ is a directory that contains an `index.md` file and zero or more resources. Analogous to a physical leaf, a leaf bundle is at the end of a branch. It has no descendants.
28
29 branch bundle
30 : A _branch bundle_ is a directory that contains an `_index.md` file and zero or more resources. Analogous to a physical branch, a branch bundle may have descendants including leaf bundles and other branch bundles. Top-level directories with or without `_index.md` files are also branch bundles. This includes the home page.
31
32 > [!NOTE]
33 > In the definitions above and the examples below, the extension of the index file depends on the [content format](g). For example, use `index.md` for Markdown content, `index.html` for HTML content, `index.adoc` for AsciiDoc content, etc.
34
35 ## Comparison
36
37 Page bundle characteristics vary by bundle type.
38
39 | | Leaf bundle | Branch bundle |
40 |---------------------|--------------------------------------------------------|---------------------------------------------------------|
41 | Index file | `index.md` | `_index.md` |
42 | Example | `content/about/index.md` | `content/posts/_index.md` |
43 | [Page kinds](g) | `page` | `home`, `section`, `taxonomy`, or `term` |
44 | Template types | [single][] | [home][], [section][], [taxonomy][], or [term][] |
45 | Descendant pages | None | Zero or more |
46 | Resource location | Adjacent to the index file or in a nested subdirectory | Same as a leaf bundles, but excludes descendant bundles |
47 | [Resource types](g) | `page`, `image`, `video`, etc. | all but `page` |
48
49 Files with [resource type](g) `page` include content written in Markdown, HTML, AsciiDoc, Pandoc, reStructuredText, and Emacs Org Mode. In a leaf bundle, excluding the index file, these files are only accessible as page resources. In a branch bundle, these files are only accessible as content pages.
50
51 ## Leaf bundles
52
53 A _leaf bundle_ is a directory that contains an `index.md` file and zero or more resources. Analogous to a physical leaf, a leaf bundle is at the end of a branch. It has no descendants.
54
55 ```tree
56 content/
57 ├── about
58 │ └── index.md
59 ├── posts
60 │ ├── my-post
61 │ │ ├── content-1.md
62 │ │ ├── content-2.md
63 │ │ ├── image-1.jpg
64 │ │ ├── image-2.png
65 │ │ └── index.md
66 │ └── my-other-post
67 │ └── index.md
68 └── another-section
69 ├── foo.md
70 └── not-a-leaf-bundle
71 ├── bar.md
72 └── another-leaf-bundle
73 └── index.md
74 ```
75
76 There are four leaf bundles in the example above:
77
78 about
79 : This leaf bundle does not contain any page resources.
80
81 my-post
82 : This leaf bundle contains an index file, two resources of [resource type](g) `page`, and two resources of resource type `image`.
83
84 - content-1, content-2
85
86 These are resources of resource type `page`, accessible via the [`Resources`][] method on the `Page` object. Hugo will not render these as individual pages.
87
88 - image-1, image-2
89
90 These are resources of resource type `image`, accessible via the `Resources` method on the `Page` object
91
92 my-other-post
93 : This leaf bundle does not contain any page resources.
94
95 another-leaf-bundle
96 : This leaf bundle does not contain any page resources.
97
98 > [!NOTE]
99 > Create leaf bundles at any depth within the `content` directory, but a leaf bundle may not contain another bundle. Leaf bundles do not have descendants.
100
101 ## Branch bundles
102
103 A _branch bundle_ is a directory that contains an `_index.md` file and zero or more resources. Analogous to a physical branch, a branch bundle may have descendants including leaf bundles and other branch bundles. Top-level directories with or without `_index.md` files are also branch bundles. This includes the home page.
104
105 ```tree
106 content/
107 ├── branch-bundle-1/
108 │ ├── _index.md
109 │ ├── content-1.md
110 │ ├── content-2.md
111 │ ├── image-1.jpg
112 │ └── image-2.png
113 ├── branch-bundle-2/
114 │ ├── a-leaf-bundle/
115 │ │ └── index.md
116 │ └── _index.md
117 └── _index.md
118 ```
119
120 There are three branch bundles in the example above:
121
122 home page
123 : This branch bundle contains an index file, two descendant branch bundles, and no resources.
124
125 branch-bundle-1
126 : This branch bundle contains an index file, two resources of [resource type](g) `page`, and two resources of resource type `image`.
127
128 branch-bundle-2
129 : This branch bundle contains an index file and a leaf bundle.
130
131 > [!NOTE]
132 > Create branch bundles at any depth within the `content` directory. Branch bundles may have descendants.
133
134 ## Headless bundles
135
136 Use [build options][] in front matter to create an unpublished leaf or branch bundle whose content and resources you can include in other pages.
137
138 [`Resources`]: /methods/page/resources/
139 [build options]: /content-management/build-options/
140 [home]: /templates/types/#home
141 [page resources]: /content-management/page-resources/
142 [section]: /templates/types/#section
143 [single]: /templates/types/#single
144 [taxonomy]: /templates/types/#taxonomy
145 [term]: /templates/types/#term