HUGO

Dual hosting hugo module git repositories

I’ve recently set up a personal Gitea server which I want to use as the primary server for some Hugo modules, but I plan on mirroring to Github.

The issue is that when defining / 'get’ting the module one uses the name of the hosting service:

e.g. hugo mod init git.wildtechgarden.ca/danielfdickinson/hugoDebugTables and the corresponding get.

The problem is that most users will want the github mirror (for a variety of reasons) and I’d like that to be easier than by requiring a module ‘replacement’ override to use the github mirror.

My question is there a way to do something like:

hugo mod init danielfdickinson/hugoDebugTables and have Hugo automatically try hosting in order of preference (in my case my personal git hosting first, then github; I imagine most people would default to github first, or only)?

If so, how do I set that up for use by Hugo?

As far as I understood the system then what you use in hugo mod init can be anything as long as it is not the same module name you are using anywhere else in the same system. So call it what you want.

The proper path needs to be added to the config.toml to “find” the module. That does not need to be the same as in init.

From what I can see that means nested modules end up with the ‘parent’ module having the repo name in it’s config.toml, which means that any theme, or other module, that depends on the ‘parent’ module will use the full repo name for the nested module.

That breaks my use case. Also I’m not sure using a different path in config.toml than init is quite right when I look at the Go module documention (for which Hugo modules is a thin wrapper). It probably manages to work, but I’m not sure it’s within spec. (But that’s less of a concern than the nested module situation; vendoring helps with that, but there are often reasons to no vendor, or for a user of a nested module system to not want to use the vendoring, so the full hierarchy of hugo mod get needs (in my opinion) to be work as expected).

I had a moment of hope when I read your reply, but from my experimentation this isn’t going to be a solution that fits what I’m looking for (assuming there is one).

I guess I could probably have a script to allow using replacements (maybe involving replacements environment variables) that I could allow users to default to my primary mirror (it is supposed to primary after all), but allow users to override to Github. I want to be cross-platform so I guess that means either supplying both a ‘.sh’ and a ‘.cmd’.

The other question is how much of a hinderance is using custom hosting to folks who want to use the modules. If no one cares (and I have the scripts, which are also on github, if the hosting is down) then maybe I’m just makeing extra work for myself.

In the end though,if it’s not possible to easily support Github as an alternate module source (rather than just source code mirror), I’m going to choose my own hosting as my preference, for various reasons that are OT.