2020-03-09 15:19:32 -04:00
---
title: Build Options
2022-11-17 10:14:29 -05:00
linkTitle: Build Options
2020-03-09 15:19:32 -04:00
description: Build options help define how Hugo must treat a given page when building the site.
keywords: [build,content,front matter, page resources]
2022-11-17 10:14:29 -05:00
categories: [content management]
2020-03-09 15:19:32 -04:00
menu:
docs:
2022-11-17 10:14:29 -05:00
parent: content-management
weight: 70
2020-03-09 15:19:32 -04:00
toc: true
2022-11-17 10:14:29 -05:00
weight: 70
aliases: [/content/build-options/]
2020-03-09 15:19:32 -04:00
---
They are stored in a reserved Front Matter object named `_build` with the following defaults:
2022-03-08 13:37:17 -05:00
{{< code-toggle > }}
2020-03-09 15:19:32 -04:00
_build:
2020-10-30 04:49:15 -04:00
render: always
2020-03-31 16:10:45 -04:00
list: always
2020-03-09 15:19:32 -04:00
publishResources: true
2022-03-08 13:37:17 -05:00
{{< / code-toggle > }}
2020-03-09 15:19:32 -04:00
#### render
2022-11-17 10:14:29 -05:00
2020-10-30 04:49:15 -04:00
If `always` , the page will be treated as a published page, holding its dedicated output files (`index.html`, etc...) and permalink.
2022-11-17 10:14:29 -05:00
We extended this property from a boolean to an enum in Hugo 0.76.0. Valid values are:
2020-10-30 04:49:15 -04:00
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` .
2020-03-09 15:19:32 -04:00
#### list
2020-03-31 16:10:45 -04:00
2020-04-10 03:06:04 -04:00
Note that we extended this property from a boolean to an enum in Hugo 0.68.0.
2020-03-31 16:10:45 -04:00
Valid values are:
never
2020-06-16 08:18:51 -04:00
: The page will not be included in any page collection.
2020-03-31 16:10:45 -04:00
always (default)
: The page will be included in all page collections, e.g. `site.RegularPages` , `$page.Pages` .
local
2022-11-17 10:14:29 -05:00
: 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.
2020-03-09 15:19:32 -04:00
2020-05-06 06:12:21 -04:00
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...).
2020-03-09 15:19:32 -04:00
#### publishResources
2023-05-22 10:43:12 -04:00
If set to true the [Bundle's Resources ](/content-management/page-bundles ) will be published.
2020-03-09 15:19:32 -04:00
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 %}}
2023-05-22 10:43:12 -04:00
Any page, regardless of their build options, will always be available using the [`.GetPage` ](/functions/getpage ) methods.
2020-03-09 15:19:32 -04:00
{{% /note %}}
### Illustrative use cases
#### Not publishing a page
2022-11-17 10:14:29 -05:00
2020-03-09 15:19:32 -04:00
Project needs a "Who We Are" content file for Front Matter and body to be used by the homepage but nowhere else.
2023-05-22 10:43:12 -04:00
{{< code-toggle file = "content/who-we-are.md" fm = true copy = false > }}
2020-03-09 15:19:32 -04:00
title: Who we are
_build:
list: false
render: false
2023-05-22 10:43:12 -04:00
{{< / code-toggle > }}
2020-03-09 15:19:32 -04:00
2023-05-22 10:43:12 -04:00
{{< code file = "layouts/index.html" copy = false > }}
2020-03-09 15:19:32 -04:00
< section id = "who-we-are" >
2023-05-22 10:43:12 -04:00
{{ with site.GetPage "who-we-are" }}
{{ .Content }}
{{ end }}
2020-03-09 15:19:32 -04:00
< / section >
2023-05-22 10:43:12 -04:00
{{< / code > }}
2020-03-09 15:19:32 -04:00
#### Listing pages without publishing them
Website needs to showcase a few of the hundred "testimonials" available as content files without publishing any of them.
2023-05-22 10:43:12 -04:00
To avoid setting the build options on every testimonials, one can use [`cascade` ](/content-management/front-matter#front-matter-cascade ) on the testimonial section's content file.
2020-03-09 15:19:32 -04:00
2022-05-08 10:56:42 -04:00
{{< code-toggle > }}
2020-03-09 15:19:32 -04:00
title: Testimonials
_build:
render: true
cascade:
_build:
render: false
list: true # default
2022-05-08 10:56:42 -04:00
{{< / code-toggle > }}
2020-03-09 15:19:32 -04:00
2023-05-22 10:43:12 -04:00
{{< code file = "layouts/_defaults/testimonials.html" copy = false > }}
2020-03-09 15:19:32 -04:00
< section id = "testimonials" >
2023-05-22 10:43:12 -04:00
{{ range first 5 .Pages }}
< blockquote cite = "{{ .Params.cite }}" >
{{ .Content }}
< / blockquote >
{{ end }}
2020-03-31 16:10:45 -04:00
< / section >
2023-05-22 10:43:12 -04:00
{{< / code > }}