You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Named segments can be defined in `hugo.toml`.
* Eeach segment consists of zero or more `exclude` filters and zero or more `include` filters.
* Eeach filter consists of one or more field Glob matchers.
* Eeach filter in a section (`exclude` or `include`) is ORed together, each matcher in a filter is ANDed together.
The current list of fields that can be filtered are:
* path as defined in https://gohugo.io/methods/page/path/
* kind
* lang
* output (output format, e.g. html).
It is recommended to put coarse grained filters (e.g. for language and output format) in the excludes section, e.g.:
```toml
[segments.segment1]
[[segments.segment1.excludes]]
lang = "n*"
[[segments.segment1.excludes]]
no = "en"
output = "rss"
[[segments.segment1.includes]]
term = "{home,term,taxonomy}"
[[segments.segment1.includes]]
path = "{/docs,/docs/**}"
```
By default, Hugo will render all segments, but you can enable filters by setting the `renderSegments` option or `--renderSegments` flag, e.g:
```
hugo --renderSegments segment1,segment2
```
For segment `segment1` in the configuration above, this will:
* Skip rendering of all languages matching `n*`, e.g. `no`.
* Skip rendering of the output format `rss` for the `en` language.
* It will render all pages of kind `home`, `term` or `taxonomy`
* It will render the `/docs` section and all pages below.
Fixesgohugoio#10106
SegmentFilter: c.Segments.Config.Get(func(sstring) { logger.Warnf("Render segment %q not found in configuration", s) }, c.RootConfig.RenderSegments...),
367
372
MainSections: c.MainSections,
368
373
Clock: clock,
369
374
transientErr: transientErr,
@@ -400,6 +405,7 @@ type ConfigCompiled struct {
400
405
CreateTitlefunc(sstring) string
401
406
IsUglyURLSectionfunc(sectionstring) bool
402
407
IgnoreFilefunc(filenamestring) bool
408
+
SegmentFilter segments.SegmentFilter
403
409
MainSections []string
404
410
Clock time.Time
405
411
@@ -472,6 +478,10 @@ type RootConfig struct {
472
478
// A list of languages to disable.
473
479
DisableLanguages []string
474
480
481
+
// The named segments to render.
482
+
// This needs to match the name of the segment in the segments configuration.
483
+
RenderSegments []string
484
+
475
485
// Disable the injection of the Hugo generator tag on the home page.
0 commit comments