How I can create many categories of articles in website?

I’m new to Grav.
On a website I plan to create,
I would like to create menu with about 20 categories of articles and each category containing between 5 and 20 articles.
I’m looking at the documentation and the demo but I do not find how I can do that.
Thanks for any help.

Hi there. This functionality is built in to Grav using taxonomies and page collections.

Two taxonomies are already set by default in the admin: ‘category’ and ‘tag’

To assign an article to category/categories and/or tag(s) you add them to the page frontmatter such as:

        - category1
        - 'multi-word tag'
        - tag2
        - tag3

For a page that lists all articles from category1 for example, you would create a new page with the following in the frontmatter:

        '@taxonomy.category': category1
    limit: 8
        by: date
        dir: desc
    pagination: true

Functional example can be found here where I created a page that displays only blog posts from the visual category.

If you have more questions please don’t hesitate to ask! :slight_smile:

1 Like

Andy thank you for your answer.
I am not sure that I understood well.
You refered that with this method you suggest that my articles will be put in different categories, which is important.
But I am not sure that with this method I will have a menu of navigation.

For example:

When somebody click in a category in menu, will see the category page with a list of titles of articles.
For example when I click the category DIETS I will see the DIETS category page with these links:


Can I do this in Grav without coding? Only with wyswyg editor?
Thank you again.

That’s ok. What I posted is a somewhat complex solution. We can simplify a bit using the WYSIWYG GUI.

First, take a look at this very basic demo I threw together. For this demo instead of using taxonomy filters I am using Blog ‘parent’ pages with Item ‘child’ pages. You can still put taxonomies (categories) on the pages, but the way the blog pages are set up, the taxonomies have no influence over how the pages are grouped. I (or others) can explain this in more detail if you like…

Adding a parent page:

Adding a child page (note the differences here):

On the demo site, hover over ‘Politics’ in the nav and you will see a dropdown menu of the associated child pages. The ‘Visible’ option in the above screenshot is set to ‘Yes’ to force the page to appear in the nav, you can disable this if you prefer. Clicking on ‘Politics’ will display the Politics Main Page listing the child pages. I think this is what you’re after?

Here’s what the page tree in the admin looks like:

Let me know if this is the direction you’re after and I can provide some more instruction and/or screenshots – or others can as well :smiley:

edit/note: others may point out that there are other (maybe better?) ways of doing this, which is one of the things that makes Grav unique - its flexibility. If someone has another way of doing it I’d be interested in hearing that approach. I admit it’s a bit late here in SF…

Andy thank you again for your time to explain me with examples on your site.
This is what I have in my mind only with top menu, not side menu.
If this will be better as blog pages, I have not problem.
Tomorrow I will install grav in my site, to try to build it with this guide.
Can I put this menu on top of every page?
I found a pdf tutorial for grav 222 pages, which I think to help me, while not so as this forum.
Thank you very much Andy.
PS. SF what means?

Hey no problem, happy to help! :smiley:

Yes, by default the navigation appears on every page with that theme.

If you haven’t already, I suggest you check out the official documentation. It’s very good.

Ah. San Francisco, California, USA :sunglasses: Hello from the Golden State!

Andy because I have preference for a top menu not side menu, do you know how can do that?
With other template or some configuration?
Thank you.

Do you mean have the menu centered at the top of the page? This is likely possible by modifying CSS ul.navigation I believe.