How to use a custom config file with huge new command

I have a project with three config files:

I can do:

hugo server --config config-development.toml

But not:

hugo new blog/2018/ --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.

hugo help new lists the option --config

If can’t find your config.

I hand over another config file with the --config option. This option does not work with the new command at least not here.

Hugo Static Site Generator v0.42.1 linux/amd64 BuildDate: 2018-06-13T10:16:36Z

I am using a newer version, so that might be it, but it works for me: Hugo Static Site Generator v0.45 linux/amd64 BuildDate: 2018-07-22T14:40:41Z

If you need more troubleshooting, you’ll have to share your code. :slight_smile:

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

And use the hugo new path/to/post command.