I’m building a website that has a lot of sub-folders.
I would like to list all the sub-folders in each folder and at the lowest level the corresponding articles.
I created an _index.md in each level and it successfully creates a page for each one.
I do have difficulties with creating the lists though.
With .Data.Pages “Type” “=” “services” it lists all the sub-pages (including sub-sub-folders
I tried: where .Data.Pages “File.Dir” “=” "services/accommodation"
But then I would need a different layout on each level.
I can make the levels work in the uppermost layer (sections) but I don’t manage to create a layout for deeper levels.
I tried putting the layouts in the folders according to hugos search order without success.
I had a look at hugotest11 and hugo-theme-docdock but they are not listing the sub-pages.
Do I need to specify a layout in the frontmatter of the corresponding _index.md ?
Do I need to specify a type in the frontmatter of the corresponding _index.md ?
Could you give me some hints/big-picture on how to do this properly?
I’m sure there is a very simple way of solving my problem.
This is an excerpt from my site structure:
│ ├── apartments
│ │ ├── family_apartments.md
│ │ ├── groups_apartments.md
│ │ └── romantic_apartments.md
│ ├── Hotels
│ │ ├── 3_hotels.md
│ │ ├── 4_hotels.md
│ │ ├── parador_hotels
│ │ │ ├── aiguablava_hotel.md
│ │ │ ├── arties_hotel.m
│ │ ├── parador_hotels.md
│ │ └── student_hotels.md
│ ├── hotels. md
│ └── villas_catalonia.md
│ ├── events. md
│ ├── speakers. md
└── transportation. md
For “services” it should show accommodation, business and transportation.
In accommodation it should list "apartments, Hotels, and show "villas_catalonia."
In Hotels "3_hotels, 4_hotels, parador_hotels…"
Like a file browser that shows files and folders.
The “categories” from my template almost work this way.
I have taxonomy-terms in all the frontmatter that could help to list the content.
But I feel that I’m over-complicating this probably very simple task.
Sorry if I’m wasting your time! If you point me to some example-site with a similar structure I will figure it out by myself. I spent a long time searching the forums but I can only find examples for relatively “flat” sites.
OK! It works now!
What I wanted seems to be the default-behavior of Hugo
I think the problem was that I didn’t have _index.md’s all the way down to the deepest sub-sub-folder.
Now I do and it works as expected.
I think my problem was solved by putting an _index.md in all the sub and sub-sub…-folders.
Now my problem is how to stop it from listing everything and make a page with all the sub-pages without linking to each single article.
If it was possible to use a different layout for the sub-sub-sections I could simply copy the normal list-template and remove the links, but that doesn’t seem to be possible.
My list template is a modified one from “hugo-universal-theme”.
If you want I can send it to you.