Hi, I have a question about the ignoreImports
config option for modules.
Scenario
I’m using hugo modules for sourcing content files from multiple different repositories in our organization. It’s a way for us to have the content live closer to the code in those repositories, while still allowing us to build a single, unified documentation site.
The repositories I’m sourcing content from are also Go projects, and in some cases they’re dependent on one another. For example, say I’m importing content from the following repositories (which are also Go projects)
github.com/org/a
github.com/org/b
And let’s say org/a
imports a package from org/b
, i.e. github.com/org/b/somepkg
is a dependency of org/a
. So the dependency chart would look something like this:
Observation
What I’ve noticed here is that when org/a
depends on a version of org/b
, and because these are Go projects, Hugo’s module system automatically fetches the version of org/b
required by org/a
.
For the hugo project that imports these two repositories as modules, I would like to ignore all transitive dependencies for the modules that I import, and instead define the versions of org/a
and org/b
in the go.mod
of my Hugo project. For this purpose, I’ve tried to use the ignoreImports
option in my Hugo config, but that doesn’t seem to do what I’m after. Even after enabling ignoreImports
, Hugo still resolves the transitive dependency versions.
So instead what I’m doing now is to use the replace
directive in my site’s go.mod
for all the dependencies. When I update the module versions in my site, here’s what I do:
$ hugo mod get github.com/org/a@vx.y.z
$ go mod edit -replace github.com/org/a=github.com/org/a/vx.y.z
Reproducer
I have a small reproducer of what happens with ignoreImports
without a replace directive if you want to check it:
$ git clone git@github.com:dvdksn/some-hugo-site.git
$ cd some-hugo-site
$ git checkout update-module
$ ./update.sh
Question
Did I misinterpret the purpose of ignoreImports
? Is there a better solution for importing content from hugo modules that are also Go projects?