I am creating a website project that has online courses and blog posts.
It has two sections - courses and blogs.
The directory structure looks something like this:
content |_______blog | |_______post-1 | | |_______'index.md' | |_______post-2 | |_______'index.md' | |_______course |_______course-1 | |_______ '_index.md' | |_______chapter | |_______'chapter01.md' | |_______'chapter02.md' | |_______course-2 |_______ '_index.md' |_______chapter |_______'chapter01.md' |_______'chapter02.md'
The blog section is absolutely fine.
The course section, however has nested branch bundles. This was required as each course would have its own landing page (_index.md) and may have multiple chapters (chapter01.md, etc) in that course.
I created a separate layout for the course section to display the course landing page and the chapters.
The categories under which each course falls are defined in the front matter of the ‘_index.md’ file present directly under the course directory.
With this setup the navigation between the courses is now easy. However, the default taxonomy aggregation no longer works.
That is, the ‘/categories’ page is now blank.
If I change the structure of the Course Page Bundles from Branch to Leaf (that is if I change _index.md to index.md under the individual course), then the ‘/categories’ page works fine and picks up the categories taxonomy from the front matter of the index.md of the course. But then, I am no longer allowed to nest it further to include chapters within the course directory.
It looks like the taxonomies are collected only from the regular pages and not the section pages.
I thought about creating a layout for ‘categories.terms.html’ to overcome this, where I can loop through the $.Site.Sections to collect the information and display them. But then, the user may want to click a category and I would also need to create the page that would display the courses tagged with that category. I am not sure how to do this?
For example, if my ‘/categories’ page show 3 categories - ‘music’, ‘fine-arts’ and ‘dancing’
The user may want to click on ‘music’ category that should take the user to ‘/categories/music’
I am not sure how to create this layout?
Also, it seems to me that I may be complicating things a bit and maybe doing something wrong somewhere. Maybe Hugo has a better in-built solution to the problem I am trying to solve.
I would appreciate if someone could suggest a way around this.
Hugo version: v0.62.2-83E50184 windows/amd64 BuildDate: 2020-01-05T18:53:21Z