← Back to home

Git static site generator tool

Simple static html site generator for multiple git repos.

gshr is a simple static html site generator for multiple git repos.[0] I wrote it as a fun little project because I haven’t written Go in a while. You can browse the full code inside the gshr-generated site itself at git.vogt.world but I’ve also got it up on GitHub at vogtb/gshr.

Here’s a screenshot.

Screenshot of 'gshr' showing the commit log page

It produces a single output directory for multiple repos, with…

Here’s a rough outline of what it produces:

output
├── favicon.ico
├── gshr
│   ├── commit
│   │   ├── 069606b3fcd2f96fc4349943326fb31f9d3c561f
│   │   │   └── index.html
│   │   │   ...
│   │   │   ...
│   │   └── fe47541cb62d6f513734089afda72ddefe672924
│   │       └── index.html
│   ├── files
│   │   ├── LICENSE
│   │   │   └── index.html
│   │   ├── Makefile
│   │   │   └── index.html
│   │   ├── README.md
│   │   │   └── index.html
│   │   │   ...
│   │   │   ...
│   │   ├── main.go
│   │   │   └── index.html
│   │   └── templates
│   │       ├── commit.html
│   │       │   └── index.html
│   │       │   ...
│   │       │   ...
│   │       └── partials.html
│   │           └── index.html
│   ├── files.html
│   └── log.html
├── gshr.css
├── gshr.git
│   ├── HEAD
│   ├── config
│   ├── index
│   ├── info
│   │   └── refs
│   ├── objects
│   │   ├── info
│   │   │   └── packs
│   │   └── pack
│   │       ├── pack-a6e75f15316a2d809290159b8bdc88303c8090cb.idx
│   │       └── pack-a6e75f15316a2d809290159b8bdc88303c8090cb.pack
│   └── refs
│       ├── heads
│       │   └── main
│       ├── remotes
│       │   └── origin
│       │       └── main
│       └── tags
└── index.html

It’s super simple, and not a replacement for GitHub, Gitlab, or GOGs. For instance, it doesn’t do branches, and it only renders files for the current HEAD commit on whatever default branch is set on the cloned repo.

But it does allow you to host a clone-able repo. It runs git update-server-info for each repo in the config, and renames each repo’s .git dir to {name}.git in the output directory, so you can clone from the static source. For example, you can run git clone https://git.vogt.world/gshr.git and it works as if there were a live git server.

See for yourself.

git clone https://git.vogt.world/gshr.git
cd gshr
make dev-example-go-git

Which basically runs this.

./target/gshr.bin -c=dev-example-go-git.toml -o=target/output
cd target/output
python3 -m http.server 80

With this config:

[site]
base_url = "http://localhost/"
name = "example of a couple go repos on github"

[[repos]]
name = "go-git"
description = "A highly extensible Git implementation in pure Go."
url = "https://github.com/go-git/go-git"
alt_link = "https://github.com/go-git/go-git"

I should warn you that it make take a minute or more to complete because it needs to generate static pages for each file and commit.

Just a fun little one-off project.


  • [0] gshr probably stands for "git static hosting repo" but to be honest, I don't remember why I named it that. In all likelihood I was trying to type "grsg" or "gsrh" or something that makes a little more sense.
git | programming | go | projects
2023-04-07