Skip to content
How to handle Go modules in Hugo

How to handle Go modules in Hugo

For full info about Hugo Modules see: Hugo Modules, in Hugo’s official documentation.

Hugo theme installed via Go Modules

When you install a Hugo theme via Go Modules, the theme files are stored inside your local Go module cache, not within your project directory.

Where to Find the Files

On your local machine, the source files for hugo-theme’s will be located inside your system’s global Go cache directory, specifically at this path:

Linux/macOS:

~/go/pkg/mod/github.com/........

Windows:

%USERPROFILE%\go\pkg/mod\github.com\!mc!shelby\hugo-theme-relearn@v0.0.0-20261031142426-144358d6fbaa\layouts\partials\content.html

Note

Note: Go lowercases capital letters in the cache paths by prefixing them with an exclamation mark, which is why McShelby becomes !mc!shelby.

The Easiest Way to Copy files from the theme

Instead of hunting through hidden system directories, you can use Hugo’s built-in vendor command to safely bring the files directly into your project.

  1. Vendor the theme files temporarily: Run the following command in your project root:
hugo mod vendor

This will create a _vendor folder in your project directory containing all the files for the Relearn theme.

  1. Copy the file you need: Go into _vendor/://github.com and copy it.

  2. Paste it into your project override path: Place the copied file at your local project root:

layouts/partials/content.html

Hugo will now automatically prioritize your local version over the one in the theme.

  1. Clean up: Once you have copied the file, you can safely delete the entire temporary _vendor folder. Your local file overrides will remain active.

The End