A while ago I had built a rudimentary “plugin” system into my theme Midnight and now that Hugo Modules are out, I’ve been trying to break optional behavior out of the main repo and into modules. I keep getting errors though and I’m not sure what is causing the problem.
Links to relevant repos will be provided at the bottom of this post. I’m using the latest GitHub release of Hugo for FreeBSD.
Hugo Static Site Generator v0.58.2-253E5FDC freebsd/amd64 BuildDate: 2019-09-13T08:04:29Z
Module Does Not Exist
The first issue I run into is that
hugo mod get -u seems to download all of the modules correctly, but will then print an error on the last module:
Error: module "[NAME]" not found; either add it as a Hugo Module or store it in "[THEME_DIR]".: module does not exist
I tried shuffling the import order around in
config.toml and it always errors only on the last module. I have run
hugo mod init in all of the module repos and configured
[module] inside of their configuration files.
File Does Not Exist
To see if I could work around the above issue, I replaced the import paths from module paths to the name of the local folder inside
themes/ so it wouldn’t try to fetch them. That led to another error:
Error: add site dependencies: load resources: loading templates: walk: open "[FOLDER]" (""): file does not exist
[FOLDER] is the last folder in a mount configured in the module itself. So for example, the commento plugin has the following configuration:
[module] [[module.mounts]] source = "partials" target = "layouts/partials/comments/commento" [[module.mounts]] source = "css" target = "assets/css/comments/commento"
The error would then say
... open "commento" (""): file does not exist. In this case it’s referring to the “partials” mount target (determined by changing the name of the last folder in both targets). This error occurs with multiple modules, though, which is why I generalized the error message.
Another user mentioned having this error in another thread but there has been no response.
Could someone take a look at my repos and try and help debug these issues? The theme is a bit complex, but knowledge of the innards shouldn’t be necessary. The modules I’ve split off were copied directly, with the only changes being that a folder, e.g.
layouts/partials/comments/commento, had the unnecessary empty parent folders removed, e.g.
/partials, but the mounts are configured to be at the same location they were before splitting…
All links point to the correct branch (all use
master except Midnight, which uses branch
config.toml files of the website and Midnight are configured to use local copies of the submodules but have commented entries to download them as modules.