'hugo new' injects language code into path | multilingual site

This problem has appeared before, without solution.

  1. Hugo new content multi lingual language

  2. Hugo new always put new files on /en/

I’ve got a strange issue with Hugo.

I’ve setup my site as multilingual, with English and Japanese.

Here is the language info in my config.toml

DefaultContentLanguage = 'en'

[languages]
	[languages.en]
		contentDir = "content/en"
		title = "My Website in English"
		languageName = "English"
		weight = "1"
	[languages.jp]
		contentDir = "content/jp"
		title = "My Website in Japanese"
		languageName = "Japanese"
		weight = "2"

Everything is working amazing as far as Hugo goes, with all the content I’ve already got in it.

But when I try to make new pages something is wrong.

Hugo inserts ‘en’ into the path.

user@computer:~/Documents/HugoProject$ hugo --verbose new -k jp jp/post/file.md
INFO 2020/06/21 23:04:31 Using config file: 
INFO 2020/06/21 23:04:31 attempting to create "jp/post/file.md" of "jp" of ext ".md"
/home/user/Documents/HugoProject/content/en/jp/post/file.md created

When I try to specify the content directory, I get the same result.

user@computer:~/Documents/HugoProject$ hugo --verbose new -k jp -c /home/user/Documents/HugoProject/content/ jp/post/file.md
INFO 2020/06/21 22:46:06 Using config file: 
INFO 2020/06/21 22:46:06 attempting to create "jp/post/file.md" of "jp" of ext ".md"
/home/user/Documents/HugoProject/content/en/jp/post/file.md created

When I try to create a file in en, it inserts en again.

user@computer:~/Documents/HugoProject$ hugo --verbose new -k en -c /home/user/Documents/HugoProject/content/ en/post/file.md
INFO 2020/06/21 22:46:06 Using config file: 
INFO 2020/06/21 22:46:06 attempting to create "en/post/file.md" of "en" of ext ".md"
/home/user/Documents/HugoProject/content/en/en/post/file.md created

When I specify the destination directory, I get the same result.

user@computer:~/Documents/HugoProject$ hugo --verbose new -k jp -d /home/user/Documents/HugoProject/content**/jp** post/file.md
INFO 2020/06/21 22:46:06 Using config file: 
INFO 2020/06/21 22:46:06 attempting to create "post/file.md" of "jp" of ext ".md"
/home/user/Documents/HugoProject/content/en/post/file.md created

If I comment out the language configuration lines in the config.toml file, Hugo returns to normal function, and does not insert the ‘en’ into the path.

This is my Hugo version:

Hugo Static Site Generator v0.72.0 linux/amd64 BuildDate: 2020-05-31T18:06:12Z

Can anyone please explain what is going on? Any thought to a solution?

Also, why does it say it isn’t loading a config file, when it obviously is changing its behavior on the basis of the config.toml?

P.S. I tried taking off the ‘-k’ and removed the en.html archetype I made. But it did not solve the problem.

P.P.S. I edited out the ** mentioned below.

Thank you.

Sorry I tried to add bold around the /en in the command output. But it appears as ** not as bold. Please understand that. Thank you.

P.S. I edited out the **. Still figuring out this site.

I tried on hugoDocs repo, it works by including the content dir in target path.

 ~/dev/repos/hugoDocs
hugo new -k functions content/zh/new-function.md
content/zh/new-function.md created
1 Like

HOLY SMOKES!

user@computer:~/Documents/HugoProject$ hugo new content/en/blah.md
content/en/blah.md created

user@computer:~/Documents/HugoProject$ hugo new content/jp/blah.md
content/jp/blah.md created

I never thought of doing that because Hugo always jammed content into the path, so I assumed it would always be there. Well it seems we may have solved three problems with one reply!

Thanks.

P.S. Thanks for making me feel stupid for struggling with this for about 2 hours! LOL

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.