I thought I understood go modules, but I am having real difficulty getting content dir’s mounted in a central repository.
I raised a PR against an existing module test repo to demonstrate:
bep:master
← metafeather:test-mount-content
opened 10:26PM - 03 Nov 22 UTC
There are many (old and new) articles/issues/discussions that state that `module… .import.mounts` should enable a user to mount directories from a remote repository under `content`, but I've been unable to do so with Hugo v0.150.0
`hugo v0.105.0-0e3b42b4a9bdeb4d866210819fc6ddcf51582ffa+extended darwin/amd64 BuildDate=2022-10-28T12:29:05Z VendorInfo=gohugoio`
`go version go1.19 darwin/amd64`
For [example](https://discourse.gohugo.io/t/hugo-module-imported-mount-appears-as-null/38297/3):
````toml
[module]
[[module.imports]]
path = 'github.com/MartijnVisser/flink-connector-elasticsearch'
[[module.imports.mounts]]
source = 'docs/content'
target = 'content'
````
and [Master Hugo Modules: Handle Content Or Assets As Modules](https://www.hugofordevelopers.com/articles/master-hugo-modules-handle-content-or-assets-as-modules/)
In an effort to remove myself from the problem, I have forked this repo that has many `mount` config examples - but not one for `content` - to demonstrate that the file `mycontent/article.md` does not get rendered at `/bep/article/`
The exact same `module.import.mount` does work if a `replacement` entry is added pointing at a locally cloned copy of `github.com/bep/hugotestmods/mymounts`.
The mount appears as expected in `hugo config mounts`:
````json
{
"path": "github.com/bep/hugotestmods/mymounts",
"version": "v1.2.0",
"time": "0001-01-01T00:00:00Z",
"owner": "project",
"dir": "/Users/metafeather/opt/src/github.com/bep/my-modular-site/_vendor/github.com/bep/hugotestmods/mymounts/",
"mounts": [
{
"source": "mycontent",
"target": "content/bep"
},
{
"source": "myassets/subfolder",
"target": "assets/images"
},
{
"source": "mydata/subfolder",
"target": "data/datakey"
}
]
}
````
Additionally `hugo mod vendor` has copied the `github.com/bep/hugotestmods/mymounts/mycontent` directory as expected.
The content is copied without rendering if the `target` is something other than `content`, e.g. `static`, so I feel this may be a regression - or I am missing something?
Thanks for you consideration.
Since modules have been around for quite a while I think there is something I am missing about the special handing of content
vs the other directories Hugo uses, so hopefully I can help get this clarified.
Thanks for the example - it works as expect with the below configs and really helps my sanity!
I’ll diff this against my own PR and my setup and see what I can learn.
[[module.imports]]
path = "github.com/jmooring/hugo-content"
[[module.imports]]
path = "github.com/jmooring/hugo-content"
[[module.imports.mounts]]
source="content"
target="content/jmooring"
[[module.imports]]
path = "github.com/jmooring/hugo-content"
[[module.imports.mounts]]
source="content/articles"
target="content/jmooring"
[[module.imports]]
path = "github.com/metafeather/hugo-content"
[[module.imports.mounts]]
source="mycontent"
target="content/metafeather"
1 Like
system
Closed
November 5, 2022, 11:34pm
4
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.