hugo/hugolib
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
..
filesystems Handle themes in the new file cache (for images, assets) 2018-11-23 21:09:00 +01:00
pagemeta Run gofmt -s 2018-10-24 00:12:32 +02:00
paths Add /config dir support 2018-12-11 13:08:36 +01:00
testdata hugolib: Add test for image processing from shortcodes 2018-01-01 12:11:36 +01:00
testsite hugolib: Add multiple content dirs to GitInfo test site 2018-08-11 19:51:19 +02:00
404_test.go Spring test cleaning, take 2 2018-03-18 09:54:32 +01:00
alias.go Make WARN the new default log log level 2018-11-03 12:06:23 +01:00
alias_test.go Add Hugo Piper with SCSS support and much more 2018-07-06 11:46:12 +02:00
author.go Revert the "standardize author data" 2016-09-18 19:16:39 +02:00
case_insensitive_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
collections.go tpl/collections: Add collections.Append 2018-09-14 10:12:08 +02:00
collections_test.go tpl/collections: Add collections.Append 2018-09-14 10:12:08 +02:00
config.go Add /config dir support 2018-12-11 13:08:36 +01:00
config_test.go Add /config dir support 2018-12-11 13:08:36 +01:00
configdir_test.go Add /config dir support 2018-12-11 13:08:36 +01:00
datafiles_test.go commands: Show server error info in browser 2018-10-16 22:10:56 +02:00
disableKinds_test.go Simplify .Site.GetPage etc. 2018-07-18 00:07:20 +02:00
embedded_shortcodes_test.go Re-organize the figure shortcode for better readability 2018-10-03 09:55:53 +03:00
embedded_templates_test.go tpl: Always load GA script over HTTPS 2018-06-09 23:47:44 +02:00
fileInfo.go commands: Show server error info in browser 2018-10-16 22:10:56 +02:00
gitinfo.go hugolib: Fix GitInfo when multiple content dirs 2018-08-11 19:51:19 +02:00
hugo_sites.go Add /config dir support 2018-12-11 13:08:36 +01:00
hugo_sites_build.go Add /config dir support 2018-12-11 13:08:36 +01:00
hugo_sites_build_errors_test.go Add file (line/col) info to ref/relref errors 2018-11-01 21:06:35 +01:00
hugo_sites_build_test.go Add /config dir support 2018-12-11 13:08:36 +01:00
hugo_sites_multihost_test.go Fix Resource output in multihost setups 2018-08-13 19:00:51 +02:00
hugo_themes_test.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
language_content_dir_test.go Add optional lang as argument to rel/relref 2018-07-18 00:07:20 +02:00
media.go Fix copyright headers in source files 2015-12-07 19:57:01 +01:00
menu.go hugolib: Remove unused code 2018-01-25 17:14:03 +01:00
menu_test.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
minify_publisher_test.go Add support for minification of final output 2018-08-06 19:58:41 +02:00
multilingual.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
orderedMap.go hugolib: Defer the unlock in orderedMap.Add 2018-04-22 21:32:05 +02:00
orderedMap_test.go hugolib: Process and render shortcodes in their order of appearance 2018-04-22 17:40:51 +02:00
page.go Add /config dir support 2018-12-11 13:08:36 +01:00
pageCache.go hugolib: Clear the page cache per render 2018-09-21 11:21:15 +02:00
pageCache_test.go hugolib: Compare every element in pages cache 2018-09-21 11:21:15 +02:00
pageGroup.go tpl/collections: Improve type handling in collections.Slice 2018-09-10 09:19:01 +02:00
pageGroup_test.go tpl/collections: Improve type handling in collections.Slice 2018-09-10 09:19:01 +02:00
pageSort.go hugolib: Fall back to title in ByLinkTitle sort 2018-11-28 13:52:26 +01:00
pageSort_test.go hugolib: Fall back to title in ByLinkTitle sort 2018-11-28 13:52:26 +01:00
page_content.go parser/pageparser: Fix handling of commented out front matter 2018-11-28 10:28:50 +01:00
page_errors.go hugolib: Continue the file context/line number errors work 2018-10-22 20:46:14 +02:00
page_output.go Fix Permalink for resource, baseURL with path and canonifyURLs set 2018-11-15 16:37:11 +01:00
page_paths.go Fix Permalink for resource, baseURL with path and canonifyURLs set 2018-11-15 16:37:11 +01:00
page_paths_test.go Fix handling of taxonomy terms containing slashes 2018-08-22 07:18:37 +02:00
page_permalink_test.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
page_ref.go Remove duplicate mapstructure depdendency 2018-11-28 00:17:43 +01:00
page_resource.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
page_taxonomy_test.go Fix handling of taxonomy terms containing slashes 2018-08-22 07:18:37 +02:00
page_test.go Add /config dir support 2018-12-11 13:08:36 +01:00
page_time_integration_test.go hugolib: Integrate new page parser 2018-10-22 20:46:13 +02:00
page_without_content.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
pagebundler.go hugolib: Rename some page_* files 2018-10-23 22:21:21 +02:00
pagebundler_capture.go Make WARN the new default log log level 2018-11-03 12:06:23 +01:00
pagebundler_capture_test.go hugolib: Rename some page_* files 2018-10-23 22:21:21 +02:00
pagebundler_handlers.go hugolib: Rename some page_* files 2018-10-23 22:21:21 +02:00
pagebundler_test.go Fix Permalink for resource, baseURL with path and canonifyURLs set 2018-11-15 16:37:11 +01:00
pagecollections.go hugolib: Rename some page_* files 2018-10-23 22:21:21 +02:00
pagecollections_test.go hugolib: Rename some page_* files 2018-10-23 22:21:21 +02:00
pagesPrevNext.go hugolib: Simplify Prev/Next 2018-03-12 22:13:25 +01:00
pagesPrevNext_test.go all: Refactor to nonglobal Viper, i18n etc. 2017-02-17 17:15:26 +01:00
pages_language_merge.go hugolib: Deprecate Pages.Sort 2018-09-21 14:23:00 +02:00
pages_language_merge_test.go Add tpl/site and tpl/hugo 2018-12-06 14:37:25 +01:00
pages_related.go hugolib: Compare every element in pages cache 2018-09-21 11:21:15 +02:00
pages_related_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
pagination.go Fix Permalink for resource, baseURL with path and canonifyURLs set 2018-11-15 16:37:11 +01:00
pagination_test.go media: Allow multiple file suffixes per media type 2018-07-10 22:13:52 +02:00
path_separators_test.go hugolib: Integrate new page parser 2018-10-22 20:46:13 +02:00
permalinker.go hugolib: Add optional outputFormat to Ref/RelRef 2017-04-04 23:09:01 +02:00
permalinks.go helpers: Consolidate MakeSegment vs MakePathSanitized 2018-10-03 15:55:25 +02:00
permalinks_test.go hugolib: Integrate new page parser 2018-10-22 20:46:13 +02:00
prune_resources.go cache/filecache: Add a cache prune func 2018-11-14 23:14:51 +01:00
resource_chain_test.go Add tests for permalink on Resource with baseURL with path 2018-11-15 08:45:15 +01:00
robotstxt_test.go Spring test cleaning, take 2 2018-03-18 09:54:32 +01:00
rss_test.go hugolib: Remove deprecated rssURI 2018-09-21 14:30:57 +02:00
shortcode.go Add inline shortcode support 2018-11-27 16:14:09 +01:00
shortcode_test.go Add inline shortcode support 2018-11-27 16:14:09 +01:00
site.go Add /config dir support 2018-12-11 13:08:36 +01:00
siteJSONEncode_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
site_benchmark_test.go Add a GetPage to the site benchmarks 2018-01-24 09:08:26 +01:00
site_output.go Run gofmt -s 2018-10-24 00:12:32 +02:00
site_output_test.go Improve minifier MIME type resolution 2018-08-28 17:00:53 +02:00
site_render.go Resolve error handling/parser related TODOs 2018-10-23 19:41:22 +02:00
site_sections.go hugolib: Improve nil handling in IsDescendant and IsAncestor 2018-11-28 12:36:59 +01:00
site_sections_test.go hugolib: Improve nil handling in IsDescendant and IsAncestor 2018-11-28 12:36:59 +01:00
site_stats_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
site_test.go cache/filecache: Add a :project placeholder 2018-11-14 23:14:51 +01:00
site_url_test.go Simplify .Site.GetPage etc. 2018-07-18 00:07:20 +02:00
sitemap.go hugolib: Fix some more Golint warnings 2016-03-23 10:10:28 +01:00
sitemap_test.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
taxonomy.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
taxonomy_test.go hugolib: Normalize permalink path segments 2018-10-03 11:02:15 +03:00
template_engines_test.go Fix broken shortcodes for Ace and Amber 2017-11-18 10:41:31 +01:00
template_test.go hugolib: Add .Site.Sites 2018-12-06 14:37:25 +01:00
testhelpers_test.go Add /config dir support 2018-12-11 13:08:36 +01:00
translations.go hugolib: Fix .IsTranslated with identical filenames 2017-11-17 19:46:32 +01:00