Comments on Blogs; what a good idea! But how to implement this on a static page? Well you will need an external provider.
There are many options that Hugo already provides, but they all require some sort of central service, which is annoying. But there is the fediverse. Actually Leah from the fediverse gave me the idea to do this in the first place, since she did it on her blog. So it must work right? Well not out of the box, sadly. Also it will depend on how your theme works. So lets explain a bit more.
What needs to be done
You will need to add two new assets that were created by Leah. She put them on her GitHub site, that hosts her blog. The first is js/fedi-comments.js and the second is css/fedi-comments.css. The CSS file I have edited slightly to make it work with the PaperMod theme. It is likely you will have to do the same if you use another theme. You can find my edit together with the rest of this pages source on Codeberg.org!
Then you will also need to put some files in the layout directory. For the PaperMod theme you will need to put a comments.html file into layouts/partials. The content you can also find in my repository. For the stack theme that Leah uses on her blog you won’t need to do this. Then you need to put Leah’s this file into layouts/partials/comments/provider. Now you will only need to tell Hugo to use all of this.
To do this add the the following to your hugo.yaml:
params:
comments:
enabled: true
provider: "fedi"
Or if you use a toml formatted config:
[comments]
enabled = true
provider = "fedi"
Good, but your pages won’t have a comment section now, since you need a fedi post for each blog post. This needs to be on an instance that has a Mastodon API. For each new post you will need to add the following in your front-matter:
comment_post:
host: <mastodon API compatible instance>
id: <post id>
Now you are all set! Have fun, and please feel free to leave a comment!
Update: Leah noticed that I ignored dark mode successfully. Now the CSS is updated to work with PaperMod dark mode as well; thank Leah very much for that! <3