Hugo JSON Comments enables self-hosted comments on your Hugo-generated website
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
.gitignore
LICENSE
README.md
hugojoco.go

README.md

Hugo JSON Comments

Hugo JSON Comments is a little Go program that listens to POST requests. If they match a specific format it processes them and saves them as JSON files into the Hugo source folder.

These files can then read using Hugo's readDir function and looped through. In the loop each of them can be read with the getJSON function. The decoded comment objects can then used to display the comments.

See http://saimiri.io/2016/06/comments-in-hugo/ for a more detailed explanation.

Note: This is still at proof-of-concept level, although I have it in production on my own site.

Installation

Usage

Typical usage might be:

$ hugojoco -source=/path/to/hugo -touch=.comment -salt=5VpsqeMX6N0IiUw3e0zfPLxDQ9J5CScvW0nQhUUWNfwziPDeDKHLA60LCsmUcsL2jfmIcChZXtnv1NhGOhpRsQ6o9OyUyeU3ZzDBlD6FTGOLInkm8dia3NuaSsPwlct4

This launches hugojoco, which then listens for incoming POST requests until terminated.

With default settings, hugojoco

  • processes comments posted at :8080/comment
  • saves each comment to ./comments directory
  • tries to look for content files in ./content directory
  • uses no salt for hashing email addresses

Switches

See hugojoco -h for options.

-source

Sets the source directory of your site. Default: "."

-content

Sets the content directory of your site relative to the source directory. Default: "content"

-comments

Sets the comments directory (that is, where the comments are saved) of your site relative to the source directory. Default: "comments"

-salt

The salt to use when hashing the email addresses for internal use. This is not intended to make the hash more secure but to make it unique for each site. Default: none

-address

The IP address to use for the server. Default: any address

-port

The port that the server listens to. Default: 8080

-path

The URL path that is used to process comments. Default: /comment

-touch

The file to modify when a comment is posted. This may be needed with some watch scripts that detect only modification of existing files, not the creation of new files or directories. This is relative to the source directory. Default: none

Using With nginx

If you are using nginx you can redirect requests to hugojoco with proxy_pass:

location /comment {
    proxy_pass http://127.0.0.1:8080;
  }