webhookdIt’s a topic which frequently resurfaces: how can people who don’t want to spend hours learning the command-line publish staticly generated websites with Hugo? The Good People of LTM said it best in Rebuilding a Solar Powered Website:
User-friendliness
Static websites are much more energy efficient than dynamic websites. However, static site generators still have a long way to go in terms of usability before they can become more mainstream and compete with tools such as WordPress. In the five years between our initial release and this one, to our surprise, no robust and user-friendly application for static site generators has appeared that could replace our current workflow. Several projects exist, but these are all dependent on proprietary cloud services. A usable graphical interface for static site generators is still where key contributions to this field can be made.
Most folks are indeed used to a Wordpress-like experience. You log in, create a post, publish and done. The “piling on the hacks” approach to resolving this with Hugo has us wiring up an additional always-on React application. You can also go for a “headless CMS” but this approach seems to be cornered by flashy startups whose tools require you run an additional server-side application, database and cache.
It requires a lot more moving parts just to publish some static files. These approaches basically break the interesting aspect that is initially attractive about static site generators. The promise of 0 maintenance set-it-and-forget-it publishing.
If you also want to avoid all that like the plague then here’s a reasonably underwhelming approach to consider.
Varia has a working solution which has been put into practice for years now. It involves wiring up a Git hook which is used on the server itself to update and publish a clone of the repository after every commit. The Gitea/Forgejo web UI is then used to add/edit content for the website.
This works until you break the site and it silently does not publish your new changes. The latest trick was to serve a log of the Hugo build directly on the website itself. This has become the “Did I break it?” button on the varia.zone footer. This allows people who are hacking away on the web editor to see what kind of errors their changes have created so they can fix them.
@adz from Offline
and elsewhere came up with another approach using webhookd.
I’m not sure they were even aiming to solve the same problem but it was
a
glorious prototype.
Instead of a Git hook, you configure a webhook alongside your published website which triggers a new build of the site. In practice, this seems to result in less system administration work for the setup and maintenance. You then configure your Gitea/Forgejo repository to fire a request at that webhook on every commit to publish the site.
This prototype quickly got out of control and went on to live its own life as a Co-op Cloud recipe which has been adopted by K&M as a way to publish several static sites.
It’s always great to see how little the wheel gets reinvented in Co-op Cloud.
Regardless if you choose the Git hook or webhook, this approach might work for you.
It’s not much hassle getting people set up with an account on a Gitea/Forgejo instance. Once they’re in, you can do a whirlwind hands-on tutorial on how to edit files, follow conventions, create new files/folders and upload images, etc. Commit a test change, break the site and show the build logs, revert the test commit and show how the website is published automatically.
I’ve generally spent max 1 hour on hands-on training and a few questions here and there afterwards. It might take longer if people have 0 familiarity with editing text files or grokking different file formats and such. It still does assume some technical knowledge or inclination to learn these kinds of things. However, it is a less brutal learning curve than having to learn how to use the command-line first.
It’s a very “duct tape” solution to make Hugo publishing more accessible. We do however maintain the principle of 0 maintenance set-it-and-forget-it publishing. No additional React app, database or cache on the server. We still have to maintain the Git hosting platform but Gitea/Forgejo is a reliable and simple tool to take care of.