hugo/commands
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
..
benchmark.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
check.go commands: Make the limit command work again 2018-04-11 09:50:19 +02:00
check_darwin.go commands: Make the limit command work again 2018-04-11 09:50:19 +02:00
commandeer.go Add /config dir support 2018-12-11 13:08:36 +01:00
commands.go Add /config dir support 2018-12-11 13:08:36 +01:00
commands_test.go Add /config dir support 2018-12-11 13:08:36 +01:00
config.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
convert.go commands: Include drafts in convert command 2018-11-24 13:11:14 +01:00
env.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
gen.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
genautocomplete.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
genchromastyles.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
gendoc.go commands: Add basic server test 2018-04-11 09:51:07 +02:00
gendocshelper.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
genman.go Add tpl/site and tpl/hugo 2018-12-06 14:37:25 +01:00
helpers.go commands: Only show Ansi escape codes if in a terminal 2018-10-26 14:33:44 +02:00
hugo.go Add /config dir support 2018-12-11 13:08:36 +01:00
hugo_windows.go Update hugo_windows.go 2018-07-22 00:09:46 +02:00
import_jekyll.go Convert the rest to new page parser code paths 2018-10-22 20:46:14 +02:00
import_jekyll_test.go Only set 'url' if permalink in metadata and remove duplicate confirm msg 2018-01-28 11:24:31 +01:00
limit_darwin.go commands: Move the commands related logic to its own file 2018-04-11 09:50:19 +02:00
limit_others.go commands: Make the limit command work again 2018-04-11 09:50:19 +02:00
list.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
new.go Fix ignored --config flag with 'new' command 2018-11-18 19:09:28 +01:00
new_content_test.go Add directory based archetypes 2018-09-23 19:27:23 +02:00
new_site.go Convert the rest to new page parser code paths 2018-10-22 20:46:14 +02:00
new_theme.go Create missing head.html partial on new theme generation 2018-06-25 12:06:45 -06:00
release.go commands: Re-add the missing releaser command 2018-04-16 08:23:32 +02:00
release_noop.go commands: Re-add the missing releaser command 2018-04-16 08:23:32 +02:00
server.go Add /config dir support 2018-12-11 13:08:36 +01:00
server_errors.go commands: Fix recently broken error template 2018-11-03 16:55:45 +01:00
server_test.go Add /config dir support 2018-12-11 13:08:36 +01:00
static_syncer.go commands: Show server error info in browser 2018-10-16 22:10:56 +02:00
version.go Add tpl/site and tpl/hugo 2018-12-06 14:37:25 +01:00