Page resources of type page
(.md, .adoc, .pdc, .html, .rst, .org) are not published. When you place these files in a leaf bundle, you can capture them with .Resources.Get
to insert content. A typical use case is snippet inclusion.
If you want to blindly copy an HTML file when publishing the site, you can place it in the static directory using the desired path. For example:
content/
├── 20240806115757/
│ └── index.md
├── 20240807121149/
│ └── index.md
├── 20240828152118/
│ ├── 20240828152118.jpg
│ └── index.md
└── _index.md
static/
├── 20240828152118/
│ └── 20240828152118.html
└── favicon.ico
https://gohugo.io/content-management/page-bundles/#comparison
Files with resource type 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.
Another approach is to capture and publish each resource of type page
. For example, you could place something like this in a single page layout:
{{ range .Resources.ByType "page" }}
{{ with resources.FromString (print $.RelPermalink .Name) .Content }}
{{ .Publish }}
{{ end }}
{{ end }}
The above won’t work with uglyURLs = true
in your site configuration.
If you don’t want to publish these resources on every page, either trigger the above with a boolean front matter value, or create a shortcode using a similar construct.