Hugo

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}@github.com/regisphilibert/mod-content-test

prints the following error:

malformed module path "https:/{username}:{token}@github.com/regisphilibert/mod-content-test": 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.

Thanks!

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 git@github.com instead of https://github.com

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.