JSONFeed and Hugo

If you’re using Hugo for your blog and you want it to support JSONFeed, a syndication format for the open web a bit like RSS and Atom, there are a couple of gotchas to be aware of that tripped me up the first time I tried to implement it myself.

First, your version of Hugo should be at least 0.20. I had 0.21, the latest at the time of writing, on my machine here, but only 0.18 on my webserver. Make sure your Hugo versions are in sync and at least 0.20.

Secondly, you need to configure Hugo to generate JSON as an output format. It doesn’t by default. Add something like this to your config.toml.

Lastly, you need the JSON feed itself. I call mine index.json and it lives in layouts/index.json. That means it’ll be accessible from /index.json on my blog. You can put it anywhere though, since you link it in your page head. See the discovery section of the documentation.

Maybe you can use mine for inspiration.

As soon as I realised JSON outputs weren’t being built by default, and that they needed at least Hugo version 0.20, it all fell into place.