How to use Hugo Modules in BitBucket Repository

Hello there! I’m currently working on incorporating Hugo modules into my websites. Instead of using GitHub, I’ve opted for a Bitbucket repository. Unfortunately, I’ve encountered some difficulties when trying to connect to the Bitbucket repository module. My suspicion is that this problem arises because the repository is set to private access. I’m curious if anyone might have a solution or some insights into resolving this issue.

What does this mean?

Hi! Sorry for not being clear with the my problem.
By ‘encountering difficulties when trying to connect to the Bitbucket repository module,’ I mean that I’m facing challenges when attempting to use a Bitbucket-hosted repository as a module in my Hugo website. Specifically, I’m trying to incorporate content, templates, or other assets from one Hugo project (the module) into another Hugo project (the main website).

The issues I’m experiencing could include errors when running the ‘hugo mod get -u’ command, authentication problems, or any other hurdles that prevent me from successfully fetching the module content from Bitbucket and integrating it into my Hugo site.

My suspicion is that these difficulties are related to the Bitbucket repository being set to private access, which may require specific authentication and permissions to access its contents. I’m seeking advice or insights on how to resolve these issues and successfully integrate the private Bitbucket repository as a module into my Hugo website. Or if someone has already successfully used Bitbucket repository as a module.

What errors? You need to be specific. Otherwise you are just wasting your time.

I’ve tested a using a private BitBucket repository for a Hugo module… no problems.

1 Like

I’m currently exploring the potential of using Hugo within my corporation. I have multiple Hugo sites and I want to include content from one Hugo site into another using Hugo modules. To achieve this, I initialized both Hugo sites as modules using the hugo mod init command. Then, I added the necessary configuration in the TOML file under [module] and [[module.imports]].

However, I’m encountering an error related to connecting to the remote repository when I try to fetch the modules. The error message I’m receiving is:

PS C:\Hugo\hugo\mysite> hugo mod get -u
hugo: downloading modules…
Error: failed to load modules: failed to get [“-d” “LINK”@upgrade"]: failed to execute ‘go
[get -d “LINK”@upgrade]’: failed to execute binary “go” with args [get -d “LINK”@upgrade]: go: “LINK”@upgrade: module “LINK”: git ls-remote -q origin in C:\Users\user\AppData\Local\Temp\2\hugo_cache\modules\filecache\modules\pkg\mod\cache\vcs\ee0da4d474173e7dca4341f8fbe2a37036f5d7b5b72d5cbdbcef2e1ef3ecbd02: exit status 128: fatal: unable to connect to “LINK”:
“LINK”[0: 00.00.000.00]: errno=Unknown error
“LINK”[0: 00.00.000.00]: errno=Unknown error

I want to ensure that I haven’t made any mistakes in setting up the Hugo modules and I’m seeking advice on how to resolve this issue. Any assistance or guidance would be greatly appreciated. Thank you!

I authenticate with BitBucket using SSH keys.

In my .gitconfig file I have:

[url "ssh://git@bitbucket.org/"]
	insteadOf = https://bitbucket.org/

And my site config file has:

[[module.imports]]
path = 'bitbucket.org/workspace/some-hugo-module'

No errors.

2 Likes