# Creating categories and subcategories

**URL:** <https://community.directus.com/t/creating-categories-and-subcategories/2184>\
**Category:** Help\
**Tags:** data-modeling\
**Created:** [April 24, 2026, 8:29am UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184 "2026-04-24T08:29:32Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Criss](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/criss/32/1088_2.png) [@Criss](https://community.directus.com/u/Criss)\
**Post date:** [April 24, 2026, 8:29am UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/1 "2026-04-24T08:29:32Z")

</div>

I’m trying to create the categories collection on the surface, I mean before delving into any coding. So I’m following some AI generated hints:

1. _ **Create a Collection:** Go to **Settings → Data Model** and create a new collection called `Categories`._
2. _ **Add Name Field:** Add a **Text Input** field called `Name`._
3. _ **Add Relationship Field:** Add a **Many-to-One** field (labeled “Parent Category” or similar)._
  - _ **Related Collection:** Select `Categories` (yes, it links to itself)._

4. _ **Configure Interface:** Ensure the field allows selecting another item from the same `Categories` collection._
5. _**Set Up Tree View (Optional):** In the collection settings, go to the “Layout” tab, choose **Tree** , and select the “Parent Category” field as the parent ID. This provides a visual folder-like structure in the content module._

Problem is already at step 3, because in the _relationship \> related collection_ field my collection is greyed out. Is it because it needs to be coded first? What am I missing.

---

<div class="post-metadata">

**Author:** ![Abdallah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/abdallah/32/105_2.png) [@Abdallah](https://community.directus.com/u/Abdallah)\
**Post date:** [April 25, 2026, 11:34am UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/2 "2026-04-25T11:34:01Z")

</div>

Steps sounds correct, not sure why your collection is greyed out, did you create it within Directus? are you able to create new items in the `categories` collection?

if not, you just need to click on the collection to “configure” it and that’s it.

---

<div class="post-metadata">

**Author:** ![Criss](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/criss/32/1088_2.png) [@Criss](https://community.directus.com/u/Criss)\
**Post date:** [April 25, 2026, 11:49am UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/3 "2026-04-25T11:49:39Z")

</div>

I read that sometimes they are greyed out but they can be inserted manually, which I did. I now seem to have created my categories/subcategories manually, and also have set the parent/child fields. I also created items. However I’m now struggling with the “Tree View” and “Group by” options which are not visible in the layout option. I have checked everything also at the server’s level and the extension is installed… I simply do not see the layout option in the single fields neither in the collections/items list.

Any hint?

---

<div class="post-metadata">

**Author:** ![Abdallah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/abdallah/32/105_2.png) [@Abdallah](https://community.directus.com/u/Abdallah)\
**Post date:** [April 25, 2026, 11:55am UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/4 "2026-04-25T11:55:05Z")

</div>

I see, many people complained about the the same [issue](https://community.directus.com/t/tree-view-table-layout-option-missing-not-present/1821?filter=activity)

So I would recommend uninstalling it (since it crashes other extensions for me) and use this extension which I personally use [Hierarchy Layout](https://github.com/codihaus/directus-extension-hierarchy-layout) until they fix the official one.

---

<div class="post-metadata">

**Author:** ![Criss](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/criss/32/1088_2.png) [@Criss](https://community.directus.com/u/Criss)\
**Post date:** [April 25, 2026, 12:01pm UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/5 "2026-04-25T12:01:27Z")

</div>

Thanks for the tip (I had wondered why there were zero downloads on the Tree View extension). I have now installed Hierarchy and it seems to work, showing me the payout option. It actually facilitates the creation of a child category because it adds a + into the parent field, so to pick the parent category at once 🙃 I still see no “tree view” option in the “parent” field of the single collection, but at least I have it in the Content layout page

---

<div class="post-metadata">

**Author:** ![Abdallah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/abdallah/32/105_2.png) [@Abdallah](https://community.directus.com/u/Abdallah)\
**Post date:** [April 25, 2026, 12:13pm UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/6 "2026-04-25T12:13:03Z")

</div>

> [@Criss](#):
>
> I now seem to have created my categories/subcategories manually, and also have set the parent/child fields.

Can you approve that you made it a self relation? as the AI suggested here?

> 1. _ **Add Relationship Field:** Add a **Many-to-One** field (labeled “Parent Category” or similar)._ \* _ **Related Collection:** Select `Categories` (yes, it links to itself)._

Cause afaik both extensions works for self relations only.

---

<div class="post-metadata">

**Author:** ![Criss](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/criss/32/1088_2.png) [@Criss](https://community.directus.com/u/Criss)\
**Post date:** [April 25, 2026, 12:23pm UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/7 "2026-04-25T12:23:38Z")

</div>

Yes I confirm that the relation was to the category itself (though I inserted the text manually as it was greyed out… which was also an AI suggestion, so it might be it’s a bug as well)

---

<div class="post-metadata">

**Author:** ![Criss](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/criss/32/1088_2.png) [@Criss](https://community.directus.com/u/Criss)\
**Post date:** [April 26, 2026, 9:12am UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/8 "2026-04-26T09:12:10Z")

</div>

hello again, after I created the catg+subcatg, which looks nice in “herarchy” view", when viewing them as a table I initially get them with parent/child names and IDs, but then also duplicated, with empty fields (see screenshot). Is this normal or something is wrong?

 ![immagine](https://us1.discourse-cdn.com/flex002/uploads/directus/original/2X/d/d9b745cce33833cbfc89d2709ebebfe1aea04957.png)

---

<div class="post-metadata">

**Author:** ![Abdallah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/abdallah/32/105_2.png) [@Abdallah](https://community.directus.com/u/Abdallah)\
**Post date:** [April 27, 2026, 9:40am UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/9 "2026-04-27T09:40:07Z")

</div>

Hello @Criss once again  
I’m not sure how your current build, but you should look like the following:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/directus/original/2X/5/5b7c295e6d8d1bbd447d97b3948ca401b6d747fc.png)  
self relation for the parent and child, the parent is m2o, and the children is the reverse (o2m)

You just need to adjust the **display** for both fields and it should look like this in the **Hierarchy layout**

 ![image](https://us1.discourse-cdn.com/flex002/uploads/directus/original/2X/c/cb845f5e74dcb771464a6c9a4f9d3dd824d656c7.png)  
And something like that in the **Table layout**  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/directus/original/2X/3/35bfc62bbd5e9921d4fe65687ca3e46a5ca11e46.png)

---

<div class="post-metadata">

**Author:** ![Criss](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/criss/32/1088_2.png) [@Criss](https://community.directus.com/u/Criss)\
**Post date:** [April 27, 2026, 9:58am UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/10 "2026-04-27T09:58:04Z")

</div>

Goodday @Abdallah Hovering the mouse on the items, parents are set “Integer/M2O”, and childs are “Alias/TreeView”. Is that already wrong? I have set the “display template” to just show “name” and I do see the items counts, however I still get “duplicated” fields in Table view. I read that the issue is due to Directus showing “joins” of the database and I have played with the filter, but I wish not to do that because it influences the Hierarchy view as well.

---

<div class="post-metadata">

**Author:** ![Abdallah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/abdallah/32/105_2.png) [@Abdallah](https://community.directus.com/u/Abdallah)\
**Post date:** [April 27, 2026, 10:06am UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/11 "2026-04-27T10:06:51Z")

</div>

> [@Criss](#):
>
> parents are set “Integer/M2O”, and childs are “Alias/TreeView”. Is that already wrong?

According to my knowledge/approach yes, I would delete the current setup (after you take a backup) and just make a o2m relation and make sure to press on the `create corresponding field` and it should work fine after you setup the display to properly show the `name`  
Give it a try and let me know if you still have issue.

---

<div class="post-metadata">

**Author:** ![Criss](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/criss/32/1088_2.png) [@Criss](https://community.directus.com/u/Criss)\
**Post date:** [April 27, 2026, 10:35am UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/12 "2026-04-27T10:35:20Z")

</div>

I have built a lot of collections intertwined with these categories, so I cannot rebuild them. However, the interface of the child field tells me that the TreeView is actually a O2M. So I think it’s only a matter of playing with the table output, in order to hide the child items from the first column. Do you (or anyone) have other suggestions?

 ![immagine](https://us1.discourse-cdn.com/flex002/uploads/directus/original/2X/b/bd139458cb2731964ad5cab3035ddf359842c059.png)

---

<div class="post-metadata">

**Author:** ![Criss](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/criss/32/1088_2.png) [@Criss](https://community.directus.com/u/Criss)\
**Post date:** [April 27, 2026, 7:56pm UTC](https://community.directus.com/t/creating-categories-and-subcategories/2184/13 "2026-04-27T19:56:42Z")

</div>

I have decided to follow @Abdallah suggestion and have deleted all parent/child and have recreated the M2O/O2M fields. I have succeeded in fixing the table/hyerarchy views, not it looks as it should be:

 ![immagine](https://us1.discourse-cdn.com/flex002/uploads/directus/original/2X/5/5d0c24342ae2a02b7525a4f0c31f90449960ef09.png)

I believe this thread is resolved! 🤩
