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...),
369
374
MainSections: c.MainSections,
370
375
Clock: clock,
371
376
transientErr: transientErr,
@@ -402,6 +407,7 @@ type ConfigCompiled struct {
402
407
CreateTitlefunc(sstring) string
403
408
IsUglyURLSectionfunc(sectionstring) bool
404
409
IgnoreFilefunc(filenamestring) bool
410
+
SegmentFilter segments.SegmentFilter
405
411
MainSections []string
406
412
Clock time.Time
407
413
@@ -474,6 +480,10 @@ type RootConfig struct {
474
480
// A list of languages to disable.
475
481
DisableLanguages []string
476
482
483
+
// The named segments to render.
484
+
// This needs to match the name of the segment in the segments configuration.
485
+
RenderSegments []string
486
+
477
487
// Disable the injection of the Hugo generator tag on the home page.
0 commit comments