Https://staticman.net brings user-generated content to static sites

Can we use this to have our own commenting system instead of depending on third party services ?

Cool service thanks for sharing.

Even I did not test it yet but it should be pretty simple to use it for hugo as well.

One thing you need to change from the path in the staticman.yml to the data-file:

  # (*) REQUIRED
  #
  # Destination path (directory) for the data files. Accepts placeholders.
  path: "data/comments/{options.page_id}"

in the comment form you can use it like:

<form method="POST" action="https://api.staticman.net/v2/entry/{{ .Site.Params.staticman.username }}/{{{ .Site.Params.staticman.repository }}/{{ .Site.Params.staticman.branch }}/">
  <input name="options[redirect]" type="hidden" value="/thanks-for-your-comment">
  <input name="options[page_id]" type="hidden" value="{{ .UniqueID }}">
  <label><input name="fields[name]" type="text">Name</label>
  <label><input name="fields[email]" type="email">E-mail</label>
  <label><textarea name="fields[message]"></textarea>Message</label>
  
  <button type="submit">Go!</button>
</form>

Manage your staticman-configuration in config.toml

[staticman]
  username = "yourgithubusername"
  repository = "reponame"
  branch = "master"

On a content page you can read the comments data like this:

    {{ range $key, $comments := .Site.Data.comments }}
        {{ if eq $key .UniqueID }}
        {{ range $comments }}
            <blockquote>{{ . | jsonify }}</blockquote>
        {{ end }}
        {{ else }}
            Write the first comment for this page!
        {{ end }}
    {{ end }}

Hope this points you in the direction to make it possible using staticman.


Edit: Just after I finished this reply I found this link with a hugo example - https://github.com/eduardoboucas/hugo-plus-staticman :slightly_smiling: