hugo/content/en/content-management/build-options.md
Bjørn Erik Pedersen d706529720 Squashed 'docs/' changes from 3f95a2ace..a393f4cf4
a393f4cf4 Add a Spellcheck GitHub Action and config
8b6b1c381 netlify: Bump to Hugo 0.93.3
84515c183 Delete deployment-with-nanobox.md
dd45f9899 Fix typos in docs
e69de81a9 Update build-options.md
7745b7891 netlify: Hubo 0.93.2
037d63364 Clarify GitHub Pages Branches
94660c34b add missing %s
325de15e2 fix link to latest release note since the release notes were moved to GitHub: https://gohugo.io/news/no-more-releasenotes-here/
dbff41d01 Update introduction.md
0ecd627f7 netlify: Hugo 0.93.1
a74e16582 Update diagrams.md
33e310956 Add Goat example to test styling
fa0100a5b Update diagrams.md
64ac75367 Adjust diagram docs
f1d600044 Update theme
95bedff1a netlify: Bump to Hugo 0.93.0
849a8437f Merge commit 'c1398b91a9f4c67876b31feb67516b252e654d3c'
c0c60c43c docs: Regenerate docs helper
2c63fe518 cod: Regen CLI docs
f33ba4e5a CodeblockContext method renames
979b47968 Move the Goat template to the correct place
2df37e9e8 Add Markdown diagrams and render hooks for code blocks
bd8037d43 Allow images to be cropped without being resized
8b2af4b49 modules: Add modules.Workspace config for Go 1.18
46b99dea1 Add --printUnusedTemplates
1285302c9 commands: Rename --i18n-warnings to printI18nWarnings
dea2242c6 commands: Rename --path-warnings, --print-men to --printPathWarnings, --printMemoryUsage
db782ea46 deps: Update github.com/alecthomas/chroma v0.9.4 => v0.10.0

git-subtree-dir: docs
git-subtree-split: a393f4cf43829011e96d109de2f039a9b05b2d16
2022-03-08 19:37:17 +01:00

119 lines
3.4 KiB
Markdown

---
title: Build Options
linktitle: Build Options
description: Build options help define how Hugo must treat a given page when building the site.
date: 2020-03-02
publishdate: 2020-03-02
keywords: [build,content,front matter, page resources]
categories: ["content management"]
menu:
docs:
parent: "content-management"
weight: 31
weight: 31 #rem
draft: false
aliases: [/content/build-options/]
toc: true
---
They are stored in a reserved Front Matter object named `_build` with the following defaults:
{{< code-toggle >}}
_build:
render: always
list: always
publishResources: true
{{< /code-toggle >}}
#### render
If `always`, the page will be treated as a published page, holding its dedicated output files (`index.html`, etc...) and permalink.
{{< new-in "0.76.0" >}} We extended this property from a boolean to an enum in Hugo 0.76.0. Valid values are:
never
: The page will not be included in any page collection.
always (default)
: The page will be rendered to disk and get a `RelPermalink` etc.
link
: The page will be not be rendered to disk, but will get a `RelPermalink`.
#### list
Note that we extended this property from a boolean to an enum in Hugo 0.68.0.
Valid values are:
never
: The page will not be included in any page collection.
always (default)
: The page will be included in all page collections, e.g. `site.RegularPages`, `$page.Pages`.
local
: The page will be included in any _local_ page collection, e.g. `$page.RegularPages`, `$page.Pages`. One use case for this would be to create fully navigable, but headless content sections. {{< new-in "0.68.0" >}}
If true, the page will be treated as part of the project's collections and, when appropriate, returned by Hugo's listing methods (`.Pages`, `.RegularPages` etc...).
#### publishResources
If set to true the [Bundle's Resources]({{< relref "content-management/page-bundles" >}}) will be published.
Setting this to false will still publish Resources on demand (when a resource's `.Permalink` or `.RelPermalink` is invoked from the templates) but will skip the others.
{{% note %}}
Any page, regardless of their build options, will always be available using the [`.GetPage`]({{< relref "functions/GetPage" >}}) methods.
{{% /note %}}
------
### Illustrative use cases
#### Not publishing a page
Project needs a "Who We Are" content file for Front Matter and body to be used by the homepage but nowhere else.
```yaml
# content/who-we-are.md`
title: Who we are
_build:
list: false
render: false
```
```go-html-template
{{/* layouts/index.html */}}
<section id="who-we-are">
{{ with site.GetPage "who-we-are" }}
{{ .Content }}
{{ end }}
</section>
```
#### Listing pages without publishing them
Website needs to showcase a few of the hundred "testimonials" available as content files without publishing any of them.
To avoid setting the build options on every testimonials, one can use [`cascade`]({{< relref "/content-management/front-matter#front-matter-cascade" >}}) on the testimonial section's content file.
```yaml
#content/testimonials/_index.md
title: Testimonials
# section build options:
_build:
render: true
# children build options with cascade
cascade:
_build:
render: false
list: true # default
```
```go-html-template
{{/* layouts/_defaults/testimonials.html */}}
<section id="testimonials">
{{ range first 5 .Pages }}
<blockquote cite="{{ .Params.cite }}">
{{ .Content }}
</blockquote>
{{ end }}
</section>