Static generator for Go module vanity URLs.
modgen
generates webpages to serve an Go module import URLs (also known as Vanity URLs).
Unlike similar projects (e.g. govanityurls), modgen
was designed to be static. This makes it possible to use static web hosting providers — like Github Pages, for example.
We are actually using Github Pages to host our own Go module import URLs, you can check the Github Actions workflow we use here!
For more informations on Go module imports, please refer to the official documentation.
go install essaim.dev/modgen/cmd/modgen@latest
Usage of modgen:
-config string
path of the configuration file (default "modgen.yaml")
-index-tmpl string
path of an optional custom index template
-module-tmpl string
path of an optional custom module template
-target string
path where the site should be generated (default "gen/")
host: essaim.dev
modules:
- path: /modgen
vcs: git
repo-url: https://github.com/essaim-dev/modgen
Note: All fields are mandatory.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{{.Host}}</title>
</head>
<body>
<h1>{{.Host}}</h1>
<ul>
{{range .Modules}}<li><a href="{{.Path}}">{{$.Host}}{{.Path}}</a></li>{{end}}
</ul>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="go-import" content="{{.Path}} {{.VCS}} {{.RepoURL}}">
<meta http-equiv="refresh" content="1; url=https://pkg.go.dev/{{.Path}}">
</head>
<body>
<h1>{{.Path}}</h1>
<p><a href="https://pkg.go.dev/{{.Path}}">See the package on pkg.go.dev</a>.</p>
</body>
</html>