Folder Structure

Can I do this in my folder structure:

* Category1 (folder name containing sub-folders is category name)
      01.article-1
          default.md
      02.article-2
         default.md
      03.article-3
         default.md
* Category2
     01.post-1
         default.md
     02.post-2
         default.md
     03.post-3
         default.md
* Category3
     01.page-1
         default.md
     02.page-2
         default.md
     03.page-3
         default.md

(etc.)

I suspect no-one understands what you are asking here.

1 Like

Ok. What I’m trying to figure out is how to group articles together by category. What I’m guessing is that all the folders belonging to a given category are all actually sub-folders of a folder with the name of the category. Example: Category1 is the name of a folder containing all the sub-folders (01.article1, 02.article2, 03.article3). What I’m trying to figure out is how do I set it up so that all the articles will be dropdown items under the top menu item that is the category of the group of folders. Does that make sense? I hope that’s understandable.

I set up the structure in that way and it doesn’t seem to want to work the way I want it to. And I am not able to find anything in the documentation or any examples of this. I’ve just been just trying to figure it out by trial and error. If someone could even just point me in the right direction, I’d be grateful.

@dpdoug, The question still lacks some important information… For example:

  • Which theme is being used?
  • What does the following mean: “it doesn’t seem to want to work the way I want it to.”
    • What have you tried?
    • What was the result?
    • And how should the result look like?

Anyway, using a clean fresh Grav install, using the following file structure:

./user/pages
├── 01.home
│   └── default.md
├── 02.typography
│   └── default.md
├── 03.category1
│   ├── 01.article1
│   │   └── default.md
│   └── 02.article2
│       └── default.md
├── 04.category2
│   ├── 01.article1
│   │   └── default.md
│   └── 02.article2
│       └── default.md
└── images

NB: Tree is being generated using $ tree user/pages | clip.exe and pasted into post.

Grav’s default theme Quark, will produce the following menu out of the box:




And the following vertical menu in mobile mode:

image

Have a look at the following templates to see how the menus are being created:

  • user/themes/quark/templates/base.html.twig
  • user/themes/quark/templates/navigation.html.twig
  • user/themes/quark/templates/macros/macros.html.twig

I’m using the theme Afterburner2 (although I could use a different theme if it suited my needs better).

One problem is that the new page that I saved is not appearing anywhere on the page – even if I make sure to save it, clear the cache and refresh the page.

A second is that a sub-page/folder that is supposed to be inside a top level folder is not underneath it in the menu when I preview the site, but appears right next to it – it seems I’m not understanding this right and doing something the wrong way.

I thought that I numbered the folders myself, but it turns out that they are automatically numbered according to the order that I create them. After they are saved the numbers disappear in the admin dashboard, but they are there in the physical structure of the directory. So if I need to change the order, I have to get on the server and physically rename the all the folders that didn’t get numbered the way I wanted them.

Since I’m transferring from Wordpress, I have an original structure I want to keep so I have all the files numbered in the order that I want them. But since the folders all get automatically numbered, I have to go to the server and rename each and every one of them so they’re in the order I want them.

Plus the top level folders that I use as categories get numbered also – and I don’t plan on having files that go in the top level folders – but the files are automatically created anyway.

Is there any way I can change this behavior? I’m just learning all the nuances of Grav, so please humor me a little. It’s been a lot of trial and error.

@dpdoug,

One problem is that the new page that I saved is not appearing anywhere on the page – even if I make sure to save it, clear the cache and refresh the page.

  • Is “the new page” a child of another page, or a child of /pages?
  • “is not appearing anywhere on the page”: What is “the page”?
  • Where is it saved in the /pages folder tree?

A second is that a sub-page/folder that is supposed to be inside a top level folder is not underneath it in the menu

Give me some time to understand this…

  • What does the created folder structure look like?
  • Is “top level folder” the same as folder /pages?
  • Sibling menu items are sibling pages in the “top level folder”.

I thought that I numbered the folders myself

How?

So if I need to change the order, I have to get on the server and physically rename the all the folders that didn’t get numbered the way I wanted them.

Sibling pages can be reordered in Admin in the “Advanced” tab by drag/drop the list of pages.

Plus the top level folders that I use as categories get numbered also – and I don’t plan on having files that go in the top level folders – but the files are automatically created anyway.

  • “Plus the top level folders that I use as categories get numbered also”:
    If they weren’t numbered, the wouldn’t be visible in the menu…

  • “and I don’t plan on having files that go in the top level folders”:
    You don’t have to when a folder is numbered.

  • “but the files are automatically created anyway”:
    When using menu ‘Add/Add Folder’, no *.md file is being generated. Only the folder is.

Yes, you may call me overly sensitive to words, details and ambiguity… :wink:

@ pamtbaau
Please forgive my ignorance, obviously there are some basic things about Grav I haven’t grasped yet.

> What does the created folder structure look like?
> Is “top level folder” the same as folder /pages?
> Sibling menu items are sibling pages in the “top level folder”.

  • Category Folder
    • Sub-folder 1
    • Sub-folder 2
    • Sub-folder 3
    • Sub-folder 4
    • Sub-folder 5

  • These 6 folders all reside in the /user/pages/ folder.
  • Category Folder has no file of its own but is meant to be the category of the folders that reside in it.
  • Each sub-folder has a default.md in it.

The idea is that when the user clicks on the category, 5 items drop down underneath it. But what happens is only the category appears at the top and nothing drops down.

Is “top level folder” the same as folder /pages?

The “top level folder” (Category folder as I call it) resides in the user/pages/ directory

Sibling menu items are sibling pages in the “top level folder”.

Yes. “Sibling menu items” (or sub-folders as I call them), reside inside the Category folder (top level folder, as I call it)

Sibling pages can be reordered in Admin in the “Advanced” tab by drag/drop the list of pages.

Interesting - I like that. I’ll give that a try.

But still there are no items dropping down from the category. What am I doing wrong here?
Sorry if my terminology is a bit ambiguous…

@dpdoug, Have a look at the default config of Afterburner2:

dropdown:
  enabled: false

I changed the setting to true and got a dropdown! That was the issue all along. It was a funky light red color, but at least it did drop down. A little progress for today… yey!

Thanks pamtbaau!