JSON API enpoints for Taxonomy Terms

Q. Has there been work on providing support for taxonomy terms as JSON as part of HUGO?

I ask because we experience a lot of issues around the way our terms API templates are currently set up, and before I dive into refactoring these to improve how I am checking for data, I’d like to see if an out-of-the-box method has been developed in the last few years.

For background — here is what we have now

A while back, I implemented terms APIs for our “topics” and “authors” on Digital.gov, based on the work that @regis talked about in his post from 2018 https://forestry.io/blog/build-a-json-api-with-hugo/ and in the Part 2 https://forestry.io/blog/hugo-json-api-part-2/ :tada:

In short, we’re storing the templates for the JSON files as shortcodes, like this:

Which are producing these outputs:

I’m not sure I understand the question?

  1. You can configure Hugo to output json for taxonomy / terms / etc
  2. You can define custom layouts for Hugo to use to output json. What you include there is up to you.
  3. Instead of shortcodes, why not use custom layouts?

@jeremyzilar I wrote a Hugo theme/component which might help you better. I’d love for you to try it, and would be able to help from there. I need to make it a full fledge Hugo Module some time soon but in the mean time it works great as a regular theme.

Thanks.

1 Like

Oooh, happy to give this a try now, thank you @regis!