Weird error while trying to mount a file in a module

I read in one of the modules related posts recently that an undocumented ability of Hugo modules mounts feature is, that it’s able to mount files instead of directories. So I tried to change

source = "data"
target = "data"


source = "data/dnb/shortcodes/config.toml"
target = "data/dnb/shortcodes/config.toml"

but I ended up with the following error:

Change of config file detected, rebuilding site.
2020-12-07 20:46:18.886 +0700
hugo: downloading modules …
hugo: collected modules in 3709 ms
ERROR 2020/12/07 20:46:22 Failed to reload config:

ERROR 2020/12/07 20:46:22 Add site dependencies: create deps: create PathSpec: build filesystems: this fs supports directories only
Rebuilt in 4112 ms

Change of config file detected, rebuilding site.
2020-12-07 20:46:46.854 +0700
WARN 2020/12/07 20:4

Am I doing it wrong or is this “feature” more or less based on the available hardware/file system?

bep mentioned a solution in another issue: Hugo Module Mounts: use root file as source

I had the same issue and loaded my file to the assets folder instead as suggested:


Then in the shortcode, I load the “asset” through the resources method and apply the transform as suggested by bep

{{ $deployProd := resources.Get "configs/deploy_prod.yaml" | transform.Unmarshal }}

Worked like a charm.

1 Like