There is no way to do this w/o relying on a third party service, over which you still would not have control as it would be a service. Even with a service created just for Hugo, it would still be a third party service. This is the issue with static sites.
As a point of philosophy, don’t seek permanence and don’t seek consistency. These things are unnatural and bring about conflict and only ever conflict within.
Having that said, I’d suggest using a well known commenting service. Either Facebook or Disqus would be best as their comments are not likely to get deleted or removed. If you’re looking for a long term solution for storing comments, I’d suggest the following:
Leave the Hugo virtual host alone (I don’t enable any backend on my static sites)
Create another virtual host in your httpd (apache/nginx).
Enable PHP or another server-side scripting language on this virtual host.
Write a script in that language to accept POST query parameters, sanitize and clean the input, and use bound parameters etc. in your SQL queries to store the comments in a database that you control on your server, which you would be able to replicate or backup.
I might create a service like this, and relesae it in the wild.
It would be three components:
- Javascript code to post/retrieve comments using AJAX from the virtualhost/db you setup.
- Backend to handle incoming post requests, and get requests for comments/comment ids, etc. in that virtualhost/db
- Server hardening, sercurity, spam protection and general InfoSec.
1, and 2, I could provide. A simple one liner to include the Javascript code. A simple server backend script. As for server security and all that, you’d have to handle that.
This also seems like re inventing the wheel, right?
The one important bit in engineering is DRY. Do not repeat yourself. But also, DRO. Don’t Repeat Others.
If someone has made a wheel, and unless you can make a better wheel, with better features, I wouldn’t bother.
I would recommend sticking with a third party service.