mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Add headless bundle support
This commit adds support for `headless bundles` for the `index` bundle type. So: ```toml headless = true ``` In front matter means that * It will have no `Permalink` and no rendered HTML in /public * It will not be part of `.Site.RegularPages` etc. But you can get it by: * `.Site.GetPage ...` The use cases are many: * Shared media galleries * Reusable page content "snippets" * ... Fixes #4311
This commit is contained in:
@@ -179,19 +179,26 @@ func (h *HugoSites) assemble(config *BuildCfg) error {
|
||||
}
|
||||
|
||||
for _, s := range h.Sites {
|
||||
for _, p := range s.Pages {
|
||||
// May have been set in front matter
|
||||
if len(p.outputFormats) == 0 {
|
||||
p.outputFormats = s.outputFormats[p.Kind]
|
||||
}
|
||||
for _, r := range p.Resources.ByType(pageResourceType) {
|
||||
r.(*Page).outputFormats = p.outputFormats
|
||||
}
|
||||
for _, pages := range []Pages{s.Pages, s.headlessPages} {
|
||||
for _, p := range pages {
|
||||
// May have been set in front matter
|
||||
if len(p.outputFormats) == 0 {
|
||||
p.outputFormats = s.outputFormats[p.Kind]
|
||||
}
|
||||
|
||||
if err := p.initPaths(); err != nil {
|
||||
return err
|
||||
}
|
||||
if p.headless {
|
||||
// headless = 1 output format only
|
||||
p.outputFormats = p.outputFormats[:1]
|
||||
}
|
||||
for _, r := range p.Resources.ByType(pageResourceType) {
|
||||
r.(*Page).outputFormats = p.outputFormats
|
||||
}
|
||||
|
||||
if err := p.initPaths(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
s.assembleMenus()
|
||||
s.refreshPageCaches()
|
||||
|
Reference in New Issue
Block a user