Hugo modules: "Error: from config: failed to resolve output format "REDIR" from site config"

My side project this week was getting to know Hugo modules. As night approaches that failed :wink:

I read and implemented the suggestions in the following two posts:

And dug through the documentation.

And still, when running hugo mod init in my site repo I get the following error:

❯ hugo mod init
Error: from config: failed to resolve output format "REDIR" from site config

There is a stale/closed issue in the repo about this error message that explains nearly nothing and fizzled out.

My config.toml has it’s theme part removed and the following new code:

[module]
[[module.imports]]
path = "github.com/davidsneighbour/dnb-hugo/packages/netlification"
disabled = false

[[module.imports.mounts]]
target = "themes/dnb-netlification"

[[module.imports]]
path = "github.com/davidsneighbour/dnb-hugo/packages/shortcodes"
disabled = false

[[module.imports.mounts]]
target = "themes/dnb-shortcodes"

[[module.imports]]
path = "github.com/davidsneighbour/dnb-garuda"
disabled = false

[[module.imports.mounts]]
target = "themes/dnb-garuda"

The folders in the path parts are initialized as modules.

Does anybody know what that error message above might mean, where it stems from?

My Go is at go version go1.15.2 linux/amd64 and installed from snap, Hugo is installed via .deb file and Hugo Static Site Generator v0.75.1-A4A7BAB7/extended linux/amd64 BuildDate: 2020-09-15T06:57:20Z

What I see in the hugo-mod-jslibs repo is that there seems to be an additional go.sum file in all modules. Never had that in any of my modules.

Wait. One step further :wink:

REDIR is my own custom netlification redirection format. It has to be added to

[outputs]
home = [ "HTML", "RSS", "Algolia", "REDIR", "HEADERS" ]

because that is not possible via the submodule config.toml.

Which solves it all. I can’t do that one as a module. :frowning: Expect a poorly worded issue in the Hugo repo :wink:

The error message isn’t related to Hugo modules … I assume you know about this output format? Is it in use, but not defined?

See above. It’s defined in one of the “modules”. If the module is a theme it works. But if the module is a module then it’s not yet initialized at the point where it’s added to the config.

I think (I may be wrong) you need to (re)add the configuration part in your upper config.toml when the namespace is “shared” and not specific to your module. I had those use case where I needed to add any parameter without specific non-clashing namespace.

I hoped so, but it does not work (or I misconfigured all involved modules by now with all the testing). The main issue is that [outputs] is not possible in modules/theme components. I opened an issue in the repo that I hope explains what I am trying to achieve.