Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Handle config slice entries (e.g. cascade) in config folder #12899

@bep

Description

@bep

See https://discourse.gohugo.io/t/cascade-yaml-in-configuration-directory/51757

my-project/
└── config/
    ├── _default/
    │   ├── hugo.toml
    │   ├── menus.en.toml
    │   ├── menus.de.toml
    │   └── params.toml
    └── production/
        └── params.toml

The above is taken from documentation, but currently the base name of every config file below config/ are either:

  • hugo or config (a full config file)
  • of a root map key in the config.

While almost all of our config entries that holds something other than a scalar value are maps, we have some slices, e.g:

  • cascade
  • permalinks (the recently reworked setup; it used to be a map)

TOML and YAML does not support "headless" arrays (JSON does), so need to figure a way around that.
There are some non-obvious decisions to make here:

We could say e.g. cascade[0].yaml, but that sounds complicated and error prone.

I suggest that we instead invent some kind of pseudo slice container, so the name of the file would be cascade.toml, but the content is something ala:

[[cascade]]
  [cascade.params]
    color = 'red'
  [cascade.target]
    kind = 'page'
    lang = '{en,de}'
    path = '/books/**'
[[cascade]]
  [cascade.params]
    color = 'blue'
  [cascade.target]
    environment = 'production'
    kind = 'page'
    path = '/films/**'

The above means that for slices, the user needs to repeat the base name in the file itself, which I think should be fairly easy to reason about.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions