New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hugo 'new' command ignores --config flag #5177

Open
ryuhhnn opened this Issue Sep 6, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@ryuhhnn

ryuhhnn commented Sep 6, 2018

I'm using Hugo in a project that requires different configurations based on the environment. I have a config directory and different config files within it such as local.config.toml. When running hugo server --config config/local.config.toml, the correct configuration is used, but running hugo new posts/test.md --config config/local.config.toml will fail, despite the --config flag being listed in the hugo help new command.

Running the hugo new command with the --config flag set produces the following error:

Error: Unable to locate Config file. Perhaps you need to create a new site.

Hugo version: Hugo Static Site Generator v0.48/extended darwin/amd64 BuildDate: unknown
OS: macOS High Sierra 10.13.6

FWIW, it seems like I'm not the only one who's come across this: https://discourse.gohugo.io/t/how-to-use-a-custom-config-file-with-huge-new-command/13089/5

@MichaelHierweck

This comment has been minimized.

Show comment
Hide comment
@MichaelHierweck

MichaelHierweck Sep 13, 2018

I can confirm this issue. (Maybe) a workaround: place an empty config.toml in the project's root directory.

MichaelHierweck commented Sep 13, 2018

I can confirm this issue. (Maybe) a workaround: place an empty config.toml in the project's root directory.

@ryuhhnn

This comment has been minimized.

Show comment
Hide comment
@ryuhhnn

ryuhhnn Sep 13, 2018

Placing an empty config.toml in the project's root directory will not work, and is not an acceptable workaround because you would want the project to be built with the proper configuration params. A workaround that I created is a Makefile that looks like:

SLIDE_NAME ?= $(shell bash -c 'read -p "Slide Name: " name; echo $$name')
new_slide:
	cp config/local.config.toml ./config.toml
	hugo new slides/$(SLIDE_NAME).md
	rm ./config.toml
	@echo "Slide created!"

Here I'm copying the config file and placing it in the root directory and then removing it after running the command. This works, but it's not a great workaround.

ryuhhnn commented Sep 13, 2018

Placing an empty config.toml in the project's root directory will not work, and is not an acceptable workaround because you would want the project to be built with the proper configuration params. A workaround that I created is a Makefile that looks like:

SLIDE_NAME ?= $(shell bash -c 'read -p "Slide Name: " name; echo $$name')
new_slide:
	cp config/local.config.toml ./config.toml
	hugo new slides/$(SLIDE_NAME).md
	rm ./config.toml
	@echo "Slide created!"

Here I'm copying the config file and placing it in the root directory and then removing it after running the command. This works, but it's not a great workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment