We have two taxonomies on digital.gov:
The data for these are stored here: https://github.com/GSA/digitalgov.gov/tree/master/data
What is the best way to build or enable JSON endpoints for all
tags or all
categories on a HUGO site?
I can’t tell if I am
- naming the template files wrong
- not understanding the path where they’d be visible
- not configuring them in the config.yml correctly
Hey @jeremyzilar I really like the digitalgov site. Just so I’m clear, which are you trying to do?
- Use Hugo’s taxonomies (i.e.
categories inside frontmatter in content files) to write to a single
.json file (e.g.
- Incorporate non-Hugo/external data from the yaml files into a
Hey @rdwatters — Thank you for replying.
I need a json endpoint that lists all the tags, and a separate file that lists all of the categories (as JSON).
For example: https://digital.gov/tag/index.json
Here are all our JSON API endpoints: https://github.com/GSA/digitalgov.gov/wiki/APIs
You can see that a few of them are not working at the moment.
I think I just figured it out.
I had to create “pages” that included a shortcode, and each page needed to call a specific layout.
Here is the
The final output will put the JSON feed at digital.gov/tag/v1/json/
I had to add in
/v1/ into the path since we actually have JSON as a tag.
Is there any way to get the correct content encoding HTTP headers?
Good question @eberkund. I was just coming here to look up
how to set the headers in JSON files in HUGO. I am not seeing how that can be done (yet)