# Working with categories within categories

**URL:** <https://talk.jekyllrb.com/t/working-with-categories-within-categories/2664>\
**Category:** Help\
**Created:** [February 22, 2019, 10:49am UTC](https://talk.jekyllrb.com/t/working-with-categories-within-categories/2664 "2019-02-22T10:49:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mosesontheweb](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mosesontheweb/32/606_2.png) [@mosesontheweb](https://talk.jekyllrb.com/u/mosesontheweb)\
**Post date:** [February 22, 2019, 10:49am UTC](https://talk.jekyllrb.com/t/working-with-categories-within-categories/2664/1 "2019-02-22T10:49:10Z")

</div>

Hi,

I was getting rid of CMS already a while ago and like to work with Jekyll and SASS. I’m now trying to realize a new website for me presenting my geometric art, my cartoons and photos. Therefore I thought to first split this up in directories/categories:

- [mysite.com/art](http://mysite.com/art)
- [mysite.com/photo](http://mysite.com/photo)

Those three categories should be part of the top navigation in the normal menu bar. Within those categories I’d like to break it down a bit more, i.e. art in “geometric\_art”, “islamic\_geometry” and so on. This kind of second level navigation should be placed in a sidebar.

I’m shomehow stuck on how to create this within Jekyll. I usually built websites with this great tool more straight forward, this is my first attempt to a more complicated setup (for me).

Any advices or hints or tips on this from the community?

Many, many thanks in advance!

Regards, Thomas

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [February 22, 2019, 5:36pm UTC](https://talk.jekyllrb.com/t/working-with-categories-within-categories/2664/2 "2019-02-22T17:36:55Z")

</div>

you could use tags which is another built in thing like categories.

Or you can just make your own front matter called whatever you want - `subcat:geometric` and then loop thru those how ever you want.

The built in categories isn’t really all that magical, you can do much the same thing with front matter.

---

<div class="post-metadata">

**Author:** ![mosesontheweb](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mosesontheweb/32/606_2.png) [@mosesontheweb](https://talk.jekyllrb.com/u/mosesontheweb)\
**Post date:** [February 22, 2019, 7:02pm UTC](https://talk.jekyllrb.com/t/working-with-categories-within-categories/2664/3 "2019-02-22T19:02:54Z")

</div>

One thing which also came to my mind is to use collections and then either tags or categories within.

Worth trying?

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [February 22, 2019, 7:24pm UTC](https://talk.jekyllrb.com/t/working-with-categories-within-categories/2664/4 "2019-02-22T19:24:56Z")

</div>

sure, though you may want to poke around and see if cats and tags are the same for collections - I think they may be for Posts only (they have a couple special behaviors)? so if you use them somewhere else they just become front matter variables like anything else.

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [February 22, 2019, 7:45pm UTC](https://talk.jekyllrb.com/t/working-with-categories-within-categories/2664/5 "2019-02-22T19:45:46Z")

</div>

It’s not painfully obvious at first but Jekyll treats additional items in the `categories` array as subcategories (at least when used in the URL for a post). For example:

```auto
categories: [art, geometric art]

```

Will give you the parent category as `art` and the sub as `geometric art`.  
And if you use the following permalink structure in your `_config.yml`:

```auto
permalink: /:categories/:title/

```

You’ll get nice URLs like `/art/geometric-art/your-post/`

Jekyll also allows you to group posts by subfolders under `_posts` and I believe it will assign the category this way. So in theory a file like `_posts/art/geometric-art/2019-02-22-your-post.md` would give you something like `/art/geometric-art/your-post/` as well.

And have category assignments of `art` and `geometric-art`.
