summaryrefslogtreecommitdiffstats
path: root/hugolib/config_test.go
AgeCommit message (Collapse)Author
2021-10-22config: Set HUGO_ENABLEGITINFO=false override in Set_in_stringAnthony Fok
This allows TestLoadConfigWithOsEnvOverrides/Set_in_string to PASS even if there is no .git directory, e.g. during Debian package build.
2021-08-22Fix it so disableKinds etc. does not get merged in from themeBjørn Erik Pedersen
Unless the merge strategy is set up to do so. For `disableKinds` the current workaround is to make sure the project config has an entry, even if is empty: ``` disableKinds = [] ``` Note that this issue only touches root, non-map config-values that either is not set in project config or in Hugo's defaults. Fixes #8866
2021-07-28Switch to go-toml v2Bjørn Erik Pedersen
We have been using `go-toml` for language files only. This commit makes it the only TOML library. It's spec compliant and very fast. A benchark building a site with 200 pages with TOML front matter: ```bash name old time/op new time/op delta SiteNew/Regular_TOML_front_matter-16 48.5ms ± 1% 47.1ms ± 1% -2.85% (p=0.029 n=4+4) name old alloc/op new alloc/op delta SiteNew/Regular_TOML_front_matter-16 16.9MB ± 0% 16.7MB ± 0% -1.56% (p=0.029 n=4+4) name old allocs/op new allocs/op delta SiteNew/Regular_TOML_front_matter-16 302k ± 0% 296k ± 0% -2.20% (p=0.029 n=4+4) ``` Note that the front matter unmarshaling is only a small part of building a site, so the above is very good. Fixes #8801
2021-07-15Fix default values when loading from config dirBjørn Erik Pedersen
By waiting until we've loaded the config dir config before applying the default values. Fixes #8763
2021-07-03Fix panic when theme has permalinks configBjørn Erik Pedersen
Fixes #8724
2021-06-29config: Fix handling of invalid OS env config overridesBjørn Erik Pedersen
Fixes #8709
2021-06-24Fix language menu config regressionBjørn Erik Pedersen
Fixes #8672
2021-06-18Implement configuration in a directory for modulesBjørn Erik Pedersen
Fixes #8654
2021-06-14Misc config loading fixesBjørn Erik Pedersen
The main motivation behind this is simplicity and correctnes, but the new small config library is also faster: ``` BenchmarkDefaultConfigProvider/Viper-16 252418 4546 ns/op 2720 B/op 30 allocs/op BenchmarkDefaultConfigProvider/Custom-16 450756 2651 ns/op 1008 B/op 6 allocs/op ``` Fixes #8633 Fixes #8618 Fixes #8630 Updates #8591 Closes #6680 Closes #5192
2021-06-08Fix nested OS env config override when parent does not existBjørn Erik Pedersen
Fixes #8618
2021-05-30config: Fix env split to allow = character in values卜木
Fixes #8589
2021-03-20Fix OS env override for nested config param only available in themeBjørn Erik Pedersen
Fixes #8346
2021-03-14media: Make Type comparableBjørn Erik Pedersen
So we can use it and output.Format as map key etc. This commit also fixes the media.Type implementation so it does not need to mutate itself to handle different suffixes for the same MIME type, e.g. jpg vs. jpeg. This means that there are no Suffix or FullSuffix on media.Type anymore. Fixes #8317 Fixes #8324
2020-12-03all: Format code with gofumptBjørn Erik Pedersen
See https://github.com/mvdan/gofumpt
2020-11-25Allow setting the delimiter used for setting config via OS env, e.g. HUGO_Bjørn Erik Pedersen
Fixes #7829
2020-10-30Fix setting HUGO_MODULE_PROXY etc. via env varsBjørn Erik Pedersen
Fixes #7903
2019-08-12tests: Convert from testify to quicktestBjørn Erik Pedersen
2019-07-24Add Hugo ModulesBjørn Erik Pedersen
This commit implements Hugo Modules. This is a broad subject, but some keywords include: * A new `module` configuration section where you can import almost anything. You can configure both your own file mounts nd the file mounts of the modules you import. This is the new recommended way of configuring what you earlier put in `configDir`, `staticDir` etc. And it also allows you to mount folders in non-Hugo-projects, e.g. the `SCSS` folder in the Bootstrap GitHub project. * A module consists of a set of mounts to the standard 7 component types in Hugo: `static`, `content`, `layouts`, `data`, `assets`, `i18n`, and `archetypes`. Yes, Theme Components can now include content, which should be very useful, especially in bigger multilingual projects. * Modules not in your local file cache will be downloaded automatically and even "hot replaced" while the server is running. * Hugo Modules supports and encourages semver versioned modules, and uses the minimal version selection algorithm to resolve versions. * A new set of CLI commands are provided to manage all of this: `hugo mod init`, `hugo mod get`, `hugo mod graph`, `hugo mod tidy`, and `hugo mod vendor`. All of the above is backed by Go Modules. Fixes #5973 Fixes #5996 Fixes #6010 Fixes #5911 Fixes #5940 Fixes #6074 Fixes #6082 Fixes #6092
2018-12-11Add /config dir supportBjørn Erik Pedersen
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-08-28Improve minifier MIME type resolutionBjørn Erik Pedersen
This commit also removes the deprecated `Suffix` from MediaType. Now use `Suffixes` and put the MIME type suffix in the type, e.g. `application/svg+xml`. Fixes #5093
2018-07-19Add configurable ref/relref error handling and notFoundURLBjørn Erik Pedersen
Two new settings: * refLinksErrorLevel: ERROR (default) or WARNING. ERROR will fail the build. * refLinksNotFoundURL: Used as a placeholder when page references cannot be found. Fixes #4964
2018-07-15hugolib: Only set 'allThemes' if there are themes in the config fileGarry McNulty
When the 'allThemes' configuration setting is read, it will panic if there are no themes. This was a regression introduced in Hugo 0.42. Also updated a unit test to check for this. Fixes #4851
2018-07-10media: Allow multiple file suffixes per media typeBjørn Erik Pedersen
Before this commit, `Suffix` on `MediaType` was used both to set a custom file suffix and as a way to augment the mediatype definition (what you see after the "+", e.g. "image/svg+xml"). This had its limitations. For one, it was only possible with one file extension per MIME type. Now you can specify multiple file suffixes using "suffixes", but you need to specify the full MIME type identifier: [mediaTypes] [mediaTypes."image/svg+xml"] suffixes = ["svg", "abc ] In most cases, it will be enough to just change: [mediaTypes] [mediaTypes."my/custom-mediatype"] suffix = "txt" To: [mediaTypes] [mediaTypes."my/custom-mediatype"] suffixes = ["txt"] Hugo will still respect values set in "suffix" if no value for "suffixes" is provided, but this will be removed in a future release. Note that you can still get the Media Type's suffix from a template: {{ $mediaType.Suffix }}. But this will now map to the MIME type filename. Fixes #4920
2018-05-22Move the privacy config into a parentBjørn Erik Pedersen
See #4751
2018-05-21Add PrivacyEnhanced mode for YouTube to the GDPR PolicyBjørn Erik Pedersen
See #4616
2018-05-21config: Add the foundation for GDPR privacy configurationBjørn Erik Pedersen
See #4616
2018-03-21Allow themes to define output formats, media types and paramsBjørn Erik Pedersen
This allows a `config.toml` (or `yaml`, ´yml`, or `json`) in the theme to set: 1) `params` (but cannot override params in project. Will also get its own "namespace", i.e. `{{ .Site.Params.mytheme.my_param }}` will be the same as `{{ .Site.Params.my_param }}` providing that the main project does not define a param with that key. 2) `menu` -- but cannot redefine/add menus in the project. Must create its own menus with its own identifiers. 3) `languages` -- only `params` and `menu`. Same rules as above. 4) **new** `outputFormats` 5) **new** `mediaTypes` This should help with the "theme portability" issue and people having to copy and paste lots of setting into their projects. Fixes #4490
2018-03-20hugolib: Add ConfigSourceDescriptorBjørn Erik Pedersen
To prepare for config in themes See #4490
2017-08-09Add support for multiple config files via --config a.toml,b.toml,c.tomlJohan Gielstra
2017-02-17all: Refactor to nonglobal Viper, i18n etc.Bjørn Erik Pedersen
This is a final rewrite that removes all the global state in Hugo, which also enables the use if `t.Parallel` in tests. Updates #2701 Fixes #3016
2017-02-04all: Refactor to nonglobal file systemsBjørn Erik Pedersen
Updates #2701 Fixes #2951
2016-10-24all: Unify case of config variable namesAlbert Nigmatzianov
All config variables starts with low-case and uses camelCase. If there is abbreviation at the beginning of the name, the whole abbreviation will be written in low-case. If there is abbreviation at the end of the name, the whole abbreviation will be written in upper-case. For example, rssURI.
2016-09-15Make paginate settings configurable per languageBjørn Erik Pedersen
Fixes #2449
2016-09-06Make taxonomies configurable per languageBjørn Erik Pedersen
See #2312
2016-09-06Make the config loading testableBjørn Erik Pedersen
This is needed to verify #2309, but it closes a big hole in Hugo's automated tests. The loading of the config is now moved to `hugolib` and the same default settings are now used in production and tests. As Viper now uses Afero as its filesystem, we now can write fairly complete integration tests with ease. See #2309