I have a project with three config files:
config-development.toml
config-production.toml
config-staging.toml
I can do:
hugo server --config config-development.toml
But not:
hugo new blog/2018/test.md --config config-development.toml
Error: Unable to locate Config file. Perhaps you need to create a new site.
Run `hugo help new` for details.
I tried several variations of the above command but with no success.
Hugo does not find the custom config file.
What is the right usage of the hugo new command?
I have never tried that command. So I am curious: Why would you need a config file during hugo new? It’s likely that --config switch is not added to hugo new sub command.
I also had this problem when I partitioned my config.toml into 3 configs:
config-set-theme.toml
config-shared.toml
config-theme-name.toml
The way I solved this is to change the name of the first config so that my 3 config files are now:
config.toml
config-shared.toml
config-theme-name.toml
And in config.toml, I set only these variables:
themesDir
theme
newContentEditor
I think the problem is that hugo new path/to/post does not respect the --config flag and instead looks for config.toml|yaml|json. The main thing that’s needed to create a new post is the archetypeDir, which comes as part of my theme settings. Useful, but not necessary, is to launch the new post inside my newContentEditor so I set that in my config.toml too.
Now I can happily run:
hugo server --config config.toml,config-shared.toml,config-theme-name.toml