Going deeper into the hierarchy

Is there a way to get Hugo to understand a deeper site structure than say eg. /section?

This is roughly the structure I’d like to achieve;
/section.md /section/subsection1.md /section/subsection1/page1.md /section/subsection1/page2.md /section/subsection2.md /section/subsection2/page1.md

When visiting /section, the user would be presented with the content of /section.md together with links to subsection1 and subsection2.

When visiting /section/subsection1, content of /section/subsection1.md together with links to page1 and page2.

Update: I just read about the new menu in 0.14. If there were a way to automatically create a menu based on the directory tree, wouldn’t it then be possible to list all children of the current active menu item?

A tangential food for thought: If “/section” is common across all links, then maybe you can do away with “/section” altogether.

And your “/subsection1”, “/subsection2” will become the new section1 and section2.

@ashishthedev There will unfortunately be more than one section.

I take it that this is not possible to do in Hugo?

I’m looking to do something similar. I’d like to do multiple photo galleries. So

  • /gallery/trip1/index.md – description of the gallery
  • /gallery/trip1/post1.md – first post
  • /gallery/trip1/postN.md – Nth post
  • /gallery/trip2/index.md – etc.
  • /gallery/trip2/post1.md
  • /gallery/trip2/postN.md

I’d like a list of galleries, and each gallery to list out only its own posts. And each post should have prev/next navigation.

Seems like this could be possible using the path (which would be like gallery/trip1), but I don’t see where that attribute is exposed.

To confirm the requirement, the expected output (public/gallery directory) should look like:

$ Show-Tree -Path .\public\gallery -ShowLeaf
D:\Dev\test-site\public\gallery
├──trip1
│  ├──post1
│  │  └──index.html
│  ├──post2
│  │  └──index.html
│  ├──index.html
│  └──index.xml
├──trip2
│  ├──post-foo
│  │  └──index.html
│  ├──index.html
│  └──index.xml
├──index.html
└──index.xml

To solve this, you need to create a “gallery” taxonomy. See this post.
Here’s how you would set this up:

#/config.yaml
...
taxonomies:
  gallery: "gallery"
...
#/layouts/taxonomy/gallery.html
<h1> trip <N> index </h1>

this turns into your index page of all your posts for trip <N>

accessible at http://localhost/gallery/trip-n/

{{ printf "%#v" . }}
#/layouts/section/gallery.html
<h1> all trips show up here </h1>

this turns into your index page of all your trips

accessible at http://localhost/gallery/

{{ printf "%#v" . }}

Example post front-matter and location:

#/content/gallery/trip1/post1.md (yaml)
gallery:
  - "trip1"

the command would be hugo new /gallery/trip1/post1.md
_accessible at http://localhost/gallery/trip1/post1/_