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:
Bjørn Erik Pedersen
2018-01-23 14:02:54 +01:00
parent 5a0819b9b5
commit 0432c64dd2
6 changed files with 163 additions and 20 deletions

View File

@@ -508,7 +508,11 @@ func (h *HugoSites) setupTranslations() {
shouldBuild := p.shouldBuild()
s.updateBuildStats(p)
if shouldBuild {
s.Pages = append(s.Pages, p)
if p.headless {
s.headlessPages = append(s.headlessPages, p)
} else {
s.Pages = append(s.Pages, p)
}
}
}
}
@@ -560,6 +564,10 @@ func (s *Site) preparePagesForRender(cfg *BuildCfg) {
pageChan <- p
}
for _, p := range s.headlessPages {
pageChan <- p
}
close(pageChan)
wg.Wait()