Categories Missing from `categories.json` Despite Existing in the System (Custom Theme)

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:

  1. Under what conditions does Discourse omit categories from categories.json?
  2. 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.

Not sure, but is this on /latest? Maybe it includes only categories that have topics in the topic list?

1 Like

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.

FWIW I’ve just created an empty category and I can see it in my /categories.json

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.

1 Like

I’ve probably got confused. :melting_face: 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.

Don’t mind me… :slight_smile:

1 Like

It’s not clear that I’m the one who was confused. And we can both be right. I’m still not clear what it was the the OP was looking at.

1 Like

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.

You might share your code, perhaps linking to github

2 Likes