With the exception of the index
file, all of the files in a leaf bundle are page resources. Each page resource has a ResourceType
.
content/
├── leaf-bundle-1/
│ ├── a.jpg <-- page resource with ResourceType = image
│ ├── b.md <-- page resource with ResourceType = page
│ └── index.md
├── leaf-bundle-2/
│ ├── c.jpg <-- page resource with ResourceType = image
│ └── index.md
└── _index.md
Hugo supports six content formats. Page resources with any of these media types have a ResourceType
of page
. Page resources with a ResourceType
of page
are not published, and their Permalink
and RelPermalink
methods return an empty string.
We can do a better job of documenting this behavior, and the terminology isn’t great either:
https://github.com/gohugoio/hugoDocs/issues/2428
The use case for page resources with a ResouceType
of page
is to augment content. For example, create Markdown snippets that you can insert with a shortcode:
layouts/shortcodes/include-page-resource.html
{{ with .Get 0 }}
{{ with $.Page.Resources.Get . }}
{{- .RenderShortcodes }}
{{ else }}
{{ errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode requires a positional parameter indicating the relative path of the page resource to include. See %s" .Name .Position }}
{{ end }}
Then call it from content/leaf-bundle-1/index.md using the {{% %}}
notation:
{{% include-page-resource "b.md"}}
In the shortcode above, note that the third line begins with {{-
. Without this whitespace removal the result is rendered as an indented code block.