How do I use a file with Hugo?

How do I go about using Go workspaces with Hugo? I plan to use them to neatly apply replace rules for some of the modules I develop.

I also noticed that relative paths don’t work with the module.workspace option in config.yaml.

That options just sets the GOWORK env var used by Go.

As to your first question, my answer is “I’m not sure”. I was rather exited about this when it was released, but I have not had time (or priority) to investigate into how this would work with Hugo.

1 Like

Thanks for the reply. I just wanted to update the current status workspaces in Hugo, in case anyone might be interested:

  • module.workspace needs an absolute path
  • With workspace, Hugo was able to resolved nested modules in a private Hugo theme (added as a module). A good alternative to Module replacements not able to resolve nested modules · Issue #9494 · gohugoio/hugo · GitHub
  • Hugo was perfectly building the site in workspaces, however, it doesn’t watch the directories from use directive in for changes. For example, my use case was to debug a theme I’m working on. Hugo would not detect and rebuild the site if I made changes to the theme.


go 1.19

use ../../themes/hugo-yami

Thanks for testing this. Could you copy-paste the above into a GitHub issue. Both of these should be easy to fix.

Also see Make the module.workspace=off as default · Issue #10553 · gohugoio/hugo · GitHub

I’ve created the issue.

1 Like

I have played a little with work files with the latest source version of Hugo, and now it works really well. As one example, it will greatly simplify my workflow when doing theme updates on the docs site. I will cut a new release before xmas.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.