We’ve built a custom Discourse theme where specific categories are displayed on the homepage using JavaScript. The script uses a predefined list of category names (as a comma-separated array) to fetch and render content from /categories.json.
While most categories are displaying correctly, a few are missing from the homepage—even though they are explicitly listed in the script and exist in the system with valid category IDs.
Upon inspecting the /categories.json response, we found that these specific categories are not included in the API output at all. However, they:
Exist in the Discourse instance
Are top-level categories
Have everyone set with at least “See” permissions
Are not archived, hidden, or nested
We’re trying to understand:
Under what conditions does Discourse omit categories from categories.json?
How can we ensure all needed categories appear in that response, especially if we want to display them on the homepage via custom code?
Any insights or recommended solutions would be appreciated.
this is on latest discourse version and it doesn’t have any topics yet…I tried to create one dummy topic to one of the invisible category based on category ID , presuming it will invoke the categories json to list them but didn’t help & hence deleted the dummy topic as well..currently both categories has any topics…
Sounds like I’m right. It would be silly to have latest send a bunch of categories that are not used on the outage. I think what I would do is either hard code the categories you want or put them in a theme setting.
You could also make an Ajax call, but that would slow things down.
Right. I think if you get that endpoint it’ll have an categories but that the categories included in /latest are probably only those needed for those topics.
I’ve probably got confused. I thought it was about the /categories.json not including certain categories for an unknown reason and thought I’d try and rule out ones with no topics being the cause.
Thanks Pfaffman, JammyDodger. Since we’re using a customized theme, we attempted to add a few previously hidden categories to the homepage by appending them to the existing list of exposed categories in our JavaScript. We already have five categories displaying correctly using this method. However, adding these two additional categories does not result in them appearing on the homepage. To troubleshoot, we even tried posting a topic in one of them to see if that would trigger visibility, but it had no effect.