Adding Live Reload to a Static Site Generator Written in Go

11 points by bugsmith


mariusor

It's funny how we all re-implement the same things in certain aspects. I have more or less the same features in my static site generator, which is specific for SourceHut wikis: staticman :D

Feel free to crib any of the features that catch your eye.

mikejsavage

A much simpler way (like 30LOC) to do this is to go:embed all your source assets into the binary, make it hash itself at startup, add an endpoint that returns the hash, and poll that.

matklad

As per https://lobste.rs/s/qnnok5/how_make_your_own_static_site_generator#c_nwj1tk, I would encourage you to extract watching, serving & server-sent event hook into a separate binary. Go should allow you to publish a prebuilt statically linked binary, and a simple live-reload server is I think missing?

I would certainly use that, and I bet, with some marketing, a lot of other people would!