Proper way to get "private" repo's Hugo Modules?

I’ve been trying to use private repos as Hugo Modules but failed.

I think the first step I need to figure out is to write the proper hugo mod get path which includes username/password or token

Then use its base as proxy setting and eventually HUGO_MODULE_PROXY on my CI and maybe change the module config import paths to only include what should be “appended” to the proxy…

But I was not able to write the correct path.

hugo mod get https://{username}:{token}

prints the following error:

malformed module path "https:/{username}:{token}": invalid char ':'

I guess the missing slash in the error print is not related.

I know surprisingly little about this, but if all you get via Google search like “go modules private repo” should be relevant, e.g.:

Thanks, found some stuff but not this one. Will read.

Yes so most of what I had previously found was about editing your git config to use https which is fine for my local machine, but not sure how Netlify and other CI will handle…

I will start by setting this up on local, and then worry about the CI.


I think the main point here is, and this is especially true with Netlify etc., is to somehow get the default Git protocol to be SSH:

I’ve been able to make it work easy on local with having git config use instead of

Now on with Netlify.

Having them use ssh instead of https on a given site is a battle I’d rather avoid.

I was hoping to achieve this by adding a HUGO_MODULE_PROXY env var which would include a github url and token username and token.

For this I guess I need to better understand the proxy “thing”.
Is it used to build the path when using hugo mod get?

Proxy is not the road you want to take. I can see that at as a great option if you want to host “an enterprise in house proxy for your modules”, but using a public proxy for your private repos …

I think Netlify is actually using SSH keys to authenticate to GitHub (they add their keys to your account), so I suspect that should just work.

Did someone managed to share a private content module between two Hugo sites since?

1 Like

So, I have this in my Git config:


This works seamlessly for me on my … MacBook. I have little (or: none) experience with this on Netlify etc., but I assume that will work there, too, assuming the Netlify git user has access to the repos in question.

An approach (not tested by me) which would maybe be better suited for CI builds (Netlify etc.) would be:

git config --global url."https://${GITHUB_TOKEN}".insteadOf ""



Has anyone managed to get private submodules working in Netlify yet?

It would be great to get this working

A post was split to a new topic: Hugo can’t handle private modules