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/
In short, we’re storing the templates for the JSON files as shortcodes, like this:
- Authors: https://github.com/GSA/digitalgov.gov/blob/master/themes/digital.gov/layouts/shortcodes/api-authors.html
- Topics: https://github.com/GSA/digitalgov.gov/blob/master/themes/digital.gov/layouts/shortcodes/api-topics.html
Which are producing these outputs: