Unable to locate config file, perhab

Hello everyone,

I’m facing the following error at the moment:

Error: command error: Unable to locate config file or config directory. Perhaps you need to create a new site. Run hugo help new for details.

I’m executing my npm script from the root directory of my project, which is:


“hugo-dev”: “hugo server --watch --buildDrafts --cleanDestinationDir --disableFastRender --templateMetricsHints”,

I have just moved (again!) to WSL2 Ubuntu 22.04 in order to make use of the ./deploy script described in the docs.

When entering hugo server -D --config hugo.toml into my bash it works - but I don’t want that (it’s utterly annoying typing to start the server over and over again).

I have also read all the posts of this forum regarding this topic - all other problems are related differently (wrong key in config, GitLab, etc.)

Another user of this forum just cloned my site this afternoon (I did ask another question today) and got it up and running without any problems.

Why is my hugo.config file not being found ?

https://bitbucket.org/webdev-hq/tobias-hopp.de/src/master/

Hugo version?

hugo v0.131.0-bfbee17932ff24009008aa94cdd75c0c41f59279+extended linux/amd64 BuildDate=2024-08-02T09:03:48Z VendorInfo=snap:0.131.0

Does running hugo server -D (no other flags) from your Bash shell work?

Yes, it does.

It sounds like npm has the wrong working directory. This is not a Hugo issue.

Or the npm script is calling an earlier version of Hugo that looks for a config.toml file instead of a hugo.toml file.

I was able to fix it by simply renaming the folder - which is a bit odd.
But that did the trick.

NPM seems to have trouble when you have two folders with the same name nested in each other.
Why? I don’t know.

my-folder/my-folder throws it off.

Thank you for pointing me in the direction.
Regards.

1 Like

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