Working with categories within categories


#1

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:

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


#2

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.


#3

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

Worth trying?


#4

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.


#5

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:

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:

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.