# Hugo Modules without GitHub

**URL:** <https://discourse.gohugo.io/t/hugo-modules-without-github/50957>\
**Category:** support\
**Tags:** modules\
**Created:** [July 31, 2024, 3:04pm UTC](https://discourse.gohugo.io/t/hugo-modules-without-github/50957 "2024-07-31T15:04:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![asimonds](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@asimonds](https://discourse.gohugo.io/u/asimonds)\
**Post date:** [July 31, 2024, 3:04pm UTC](https://discourse.gohugo.io/t/hugo-modules-without-github/50957/1 "2024-07-31T15:04:03Z")

</div>

Hello,

I am a seasoned developer but new to Hugo and trying to get my head wrapped around Hugo modules. We are looking for a way to use Hugo Modules with either local file paths and/or our internal git repos instead of using GitHub.

Is it as simple as replacing the module reference with our internal git link?

I am hoping / expecting that there is a simple solution to avoid what is looking like a hard GitHub dependency.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [July 31, 2024, 3:22pm UTC](https://discourse.gohugo.io/t/hugo-modules-without-github/50957/2 "2024-07-31T15:22:32Z")

</div>

> [@asimonds](#):
>
> I am a seasoned developer but new to Hugo and trying to get my head wrapped around Hugo modules. We are looking for a way to use Hugo Modules with either local file paths and/or our internal git repos instead of using GitHub.

Sure. Go-Modules somehow always have to include Github for some reason. But, you can always add a `replace` configuration rule to your `go.mod`.

```golang
module github.com/some-user/some-package

replace github.com/some-user/some-package => /my/local/path/to/the/module

require (
	... automatic requires
)

```

I am not 100% sure if at any point Golang wouldn’t try to go to Github to verify something. You might want to read deeper into the whole `replace` functionality. It probably makes sense to create some form of private Github repo for the path required. You can do “deeper paths” in the form of all your modules in a single repository. The modules would still need a `go.mod` each and those can look like `github.com/some-user/some-package/modules/my-module` (for the module line in `go.mod`) where `modules/my-module/go.mod` is the path to the `go.mod` file within your mono-repo.

> **[go.mod file reference - The Go Programming Language](https://go.dev/doc/modules/gomod-ref#replace)**

Last note: a lot of GoHugo’s module functionality is Golangs module functionality with a `hugo` command in front of them. So whatever they have in their documentation might/probably will apply to GoHugo too.

---

<div class="post-metadata">

**Author:** ![asimonds](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@asimonds](https://discourse.gohugo.io/u/asimonds)\
**Post date:** [July 31, 2024, 3:30pm UTC](https://discourse.gohugo.io/t/hugo-modules-without-github/50957/3 "2024-07-31T15:30:36Z")

</div>

Thanks for the tip…

Using replace feels a little cludgy and ick however if that is how the system works it’s how it works. No use in fighting it, just need to determine if / how our strict SCA rules will mesh with that reality.

Will do a little further digging into go modules directly to try and break through this brain-blocker.

Owe you one… Thanks.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [July 31, 2024, 3:45pm UTC](https://discourse.gohugo.io/t/hugo-modules-without-github/50957/4 "2024-07-31T15:45:34Z")

</div>

> [@asimonds](#):
>
> Using replace feels a little cludgy and ick however if that is how the system works it’s how it works.

A setup I think work OK is something what you see on

> **[GitHub - gohugoio/hugoDocs: The source for https://gohugo.io/](https://github.com/gohugoio/hugoDocs)**
>
> The source for https://gohugo.io/

- Vendoring the dependencies means that people don’t need network access to build.
- Using a workspace file for development [hugoDocs/hugo.work at master · gohugoio/hugoDocs · GitHub](https://github.com/gohugoio/hugoDocs/blob/master/hugo.work)

In the setup above, if I want to make a theme change, I

- `HUGO_MODULE_WORKSPACE=hugo.work hugope server --ignoreVendorPaths "**"`
- Edit theme … Push theme
- Update theme: `hugo mod get github.com/gohugoio/gohugoioTheme`
- Vendor: hugo mod vendor

The mean reason we do this for the Docs repo is so we can include the full source in the GitHub source distributions, but it also works well in private repo setups, as only the one running “hugo mod vendor” needs access to the repo.

One other alternative would be to put your “Hugo modules” inside what’s configured as the `themesDir` in the project (default `project/themes`).

---

<div class="post-metadata">

**Author:** ![asimonds](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@asimonds](https://discourse.gohugo.io/u/asimonds)\
**Post date:** [July 31, 2024, 4:12pm UTC](https://discourse.gohugo.io/t/hugo-modules-without-github/50957/5 "2024-07-31T16:12:48Z")

</div>

Thanks for the link Bep… Will give the links a read and see what might be possible.

Once we get a test set up we can do some isolated wireshark monitoring to see how the system behaves under different configurations and verify any connection requests or potential risk for data or meta-data exfiltration.

Appreciate the info… thanks again.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [July 31, 2024, 4:28pm UTC](https://discourse.gohugo.io/t/hugo-modules-without-github/50957/6 "2024-07-31T16:28:18Z")

</div>

OK, the full list of module settings are

> **[Configure Hugo modules](https://gohugo.io/hugo-modules/configuration/)**
>
> This page describes the configuration options for a module.

One option could be to set the `proxy` option, which would make sure that modules are never fetched from GitHub. There are some fairly simple to set up Go Module Proxy servers out there.

---

<div class="post-metadata">

**Author:** ![asimonds](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@asimonds](https://discourse.gohugo.io/u/asimonds)\
**Post date:** [July 31, 2024, 9:45pm UTC](https://discourse.gohugo.io/t/hugo-modules-without-github/50957/7 "2024-07-31T21:45:25Z")

</div>

Bep,

Again, thank you for the links. Have been diving into using our old bootstrap theme as a baseline and think we may have a workable solution.

Still have some testing to do however using a baseline “hugo new theme” then starting to dive into making it work with existing templates might just do the trick. Little more work / time than we initially expected however hugo makes that work easy.

Have a much better understanding now on how the links between go modules and hugo modules function.

Appreciate the help

* * *

Edit: Came across this reference while looking into Go modules. As mentioned by others above, Hugo Modules are effectively Go Modules and Go Modules use the underlying git configuration as well.

Thought the GOPRIVATE reference might help someone so adding here.

**Go Private Modules using GOPRIVATE env variable**

> **[Go Modules Reference - The Go Programming Language](https://go.dev/ref/mod#private-modules)**
