Modules: how to specify version for some modules, and not for others

Hello I am using hugo with the docsy theme.
I would like to use modules to include both the theme and the content, published in other repository.
Using modules seems to be the recommended approach but I encountered the problem of not being able to specify, in the hugo config.yaml, a version for the theme module (docsy) and always get the latest version of the content modules.
I tried the following:

  • specify the module version in go.mod and never run hugo mod get => it honors the version for the theme module, but never updates the content modules
  • always run hugo mod get => always updates all modules, including the theme (unwanted changes)

Is there a workaround?

$ hugo help mod get

Resolves dependencies in your current Hugo Project.

Some examples:

Install the latest version possible for a given module:

    hugo mod get github.com/gohugoio/testshortcodes
    
Install a specific version:

    hugo mod get github.com/gohugoio/testshortcodes@v0.3.0

Install the latest versions of all module dependencies:

    hugo mod get -u
    hugo mod get -u ./... (recursive)

So I think you can do:

$ hugo mod get github.com/owner/repo

Thanks for the suggestion, unfortunately I couldn’t make

$ hugo mod get github.com/owner/repo

work for me, as it shows errors possibly related to incorrect theme download.

But I found a workaround which seems to be fine:

Once:

  • define modules in config.yaml
  • $ hugo mod get
  • manually modify go.mod and set the ref to the tag or branch required for each mod (remove the sha set by go mod command)
  • delete go.sum

At every “build”:

  • $ hugo (which will download modules according to go.mod, getting the latest update for each ref, but not upgrading the version to latest tag).

It’s a little cumbersome but it works.