Using gists as modules, reports "unrecognized import path"

Hi friends, when I try to use a gist as a hugo module. I receive the following error:

CLI

20:33 $ hugo
go get gist.github.com/ayersg/8d698ddfa0abe70661bdee186d283b9b@upgrade: unrecognized import path "gist.github.com/ayersg/8d698ddfa0abe70661bdee186d283b9b": parse https://gist.github.com/ayersg/8d698ddfa0abe70661bdee186d283b9b?go-get=1: no go-import meta tags ()
hugo: collected modules in 1254 ms
Error: module "gist.github.com/ayersg/8d698ddfa0abe70661bdee186d283b9b" not found; either add it as a Hugo Module or store it in "REMOVED_BY_POSTER".: module does not exist
Total in 1264 ms

config.toml

...
[[module.imports]]
path = "gist.github.com/ayersg/8d698ddfa0abe70661bdee186d283b9b"

[[module.imports.mounts]]
source = "./"
target = "static"

According to the docs a gist is a repo “Every gist is a Git repository, which means that it can be forked and cloned.”.

Separately I can of course clone the gist repo and have other modules working within the hugo repo that I’m using.

Sorry if this is my shortcoming in understanding go modules.

Thanks kindly

My Hugo Environment

hugo v0.91.0+extended darwin/amd64 BuildDate=unknown
GOOS="darwin"
GOARCH="amd64"
GOVERSION="go1.17.5"

I haven’t tried testing this, but the gist clone URLs are different. For your gist it is: https://gist.github.com/8d698ddfa0abe70661bdee186d283b9b.git. So remove the ayersg/ part from there.

image

1 Like

That works perfectly, gists as modules!!

Hugo rocks so hard :metal::laughing:

1 Like

Just remember that you’ll need to pull the latest before building:

hugo mod get gist.github.com/8d698ddfa0abe70661bdee186d283b9b.git
hugo
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.