I am new to hugo, and I find it very cool “out of the box”, but quite difficult when you try to achieve something more.
I would like to generate a categories.json with hugo, listing all the categories from my website, but I could not find resources specifically dealing with this.
How can I achieve this ? bonus point if I can sort it by number of pages with every category
The outputs definition is per Page Kind ( page , home , section , taxonomy , or taxonomyTerm ): all taxonomies will have a JSON output… Not only categories
If you want JSON only for categories, add this to the category index file Front Matter (category/_index.md):
I could not find what I was looking for: it seems so simple, yet nobody provides a handy guide to achieve this (or I could not find it).
I didn’t understand the Custom output format documentation, I find it non-intelligible (I got the theory though). Adding JSON to the outputs is not enough, you have to provide templates for that (of course), but it is fuzzy of what template to write and where to put it to see it applied. This is very confusing for a beginner IMHO.