hugo/helpers
Bjørn Erik Pedersen 7829474088
Add /config dir support
This commit adds support for a configuration directory (default `config`). The different pieces in this puzzle are:

* A new `--environment` (or `-e`) flag. This can also be set with the `HUGO_ENVIRONMENT` OS environment variable. The value for `environment` defaults to `production` when running `hugo` and `development` when running `hugo server`. You can set it to any value you want (e.g. `hugo server -e "Sensible Environment"`), but as it is used to load configuration from the file system, the letter case may be important. You can get this value in your templates with `{{ hugo.Environment }}`.
* A new `--configDir` flag (defaults to `config` below your project). This can also be set with `HUGO_CONFIGDIR` OS environment variable.

If the `configDir` exists, the configuration files will be read and merged on top of each other from left to right; the right-most value will win on duplicates.

Given the example tree below:

If `environment` is `production`, the left-most `config.toml` would be the one directly below the project (this can now be omitted if you want), and then `_default/config.toml` and finally `production/config.toml`. And since these will be merged, you can just provide the environment specific configuration setting in you production config, e.g. `enableGitInfo = true`. The order within the directories will be lexical (`config.toml` and then `params.toml`).

```bash
config
├── _default
│   ├── config.toml
│   ├── languages.toml
│   ├── menus
│   │   ├── menus.en.toml
│   │   └── menus.zh.toml
│   └── params.toml
├── development
│   └── params.toml
└── production
    ├── config.toml
    └── params.toml
```

Some configuration maps support the language code in the filename (e.g. `menus.en.toml`): `menus` (`menu` also works) and `params`.

Also note that the only folders with "a meaning" in the above listing is the top level directories below `config`. The `menus` sub folder is just added for better organization.

We use `TOML` in the example above, but Hugo also supports `JSON` and `YAML` as configuration formats. These can be mixed.

Fixes #5422
2018-12-11 13:08:36 +01:00
..
content.go helpers: Call rst2html directly on *nix 2018-10-11 22:46:10 +02:00
content_renderer.go helpers: Avoid unescape in highlight 2018-01-23 09:48:04 +01:00
content_renderer_test.go Reuse the BlackFriday instance when possible 2017-12-16 19:44:33 +01:00
content_test.go Add a BlackFriday option for rel="noreferrer" on external links 2018-05-29 16:54:43 +02:00
docshelper.go docs: Generate docshelper data 2018-04-02 08:52:42 +02:00
emoji.go helpers: Use iterate operator by int in Emojify 2016-11-23 09:13:00 +01:00
emoji_test.go Run gofmt to get imports in line vs gohugoio/hugo 2017-06-13 19:12:10 +02:00
general.go Add tpl/site and tpl/hugo 2018-12-06 14:37:25 +01:00
general_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
path.go Add /config dir support 2018-12-11 13:08:36 +01:00
path_test.go helpers: Consolidate MakeSegment vs MakePathSanitized 2018-10-03 15:55:25 +02:00
pathspec.go Fix Permalink for resource, baseURL with path and canonifyURLs set 2018-11-15 16:37:11 +01:00
pathspec_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
processing_stats.go helpers: Fix golint issues 2018-09-07 08:25:51 +02:00
pygments.go Add table linenos support for Chroma highlighter 2017-10-14 16:00:27 +02:00
pygments_test.go Add table linenos support for Chroma highlighter 2017-10-14 16:00:27 +02:00
testhelpers_test.go Add Hugo Piper with SCSS support and much more 2018-07-06 11:46:12 +02:00
url.go Fix Permalink for resource, baseURL with path and canonifyURLs set 2018-11-15 16:37:11 +01:00
url_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00