How to filter posts in categories

Hi there,
I’m Berni from germany and the total newbie in Grav. However I want to remove a website from Wordpress to a flat CMS and after some trials with SimpleCMS and Bludit I found that Grav is the best solution for men.
My website is quite simple: some static pages and a blog about motorcycles and riding. I use 5 categories for the posts : Bullet1, Bullet2, Vespa, events, something_total_different. Tags are not used yet.

Basicly the site works: static sites OK, the blog with hundred of posts and thausend of images works fine.

Now I have to solve a problem: Filtering the posts with the categories. Best would be to have a page with navbar where the categories are listed and a click activates the category filter and shows only the corresponding posts.

I read in this forums for hours and often I thought, I have the solution. But whatever I do, my page only shows all of the posts.
Firstly I was convinced that my problem is really easy to solve, but till now I did’nt find a suitable way.
I tried to enter the filter in the .md file of the page but it din’nt work.

Any hint for me? And please consider: I am that newbie! I have no basics in Grav, however I work on this. So please keep any answer as simple as possible.

Thx & regards

Did you try using collections?
I usually create a listing page (in Quark it’s blog template) for each category, and set it to display category collection, as per this docs.
Honestly I believe that there is a way to use filtering based on url params, or something like that, but this seems far easier to me personally :slight_smile:
Then you can make a category list really simply, by displaying (in sidebar or otherwise) only Pages of type Blog, or perhaps set custom header field like category and displaying given page only if it’s header.category is true… Or in a dozen of other ways :wink:
Hope this helps a bit!

Thanks a lot, @MakaryGo, that really helped. Just tried it and the category filter works perfect.
I did not understand how to create a menu with categories in the navbar, but the filter works and the rest must be figured out by me. Will try to understand your hints.

1 Like

I’m sorry, it came out way more chaotic than I planned! :joy:
Okay, so:

  1. Do you use a custom theme, or the default one?
  2. Do you wish to have the categories listed on the main (top) navbar, or in some custom location?

No reason for a sorry, you helped so much :+1:

I use the standard Quark theme. The blog with and without the filters is displayed on a separate page. This page has already a sidebar with the SimpleSearch field. There should the category list be displayed.