So re. the ongoing development of nested sections (see https://github.com/spf13/hugo/pull/3309), I have introduced some new template API. Most I’m pretty happy about, some not so much, maybe. I’ll list the important bits here.
.Page.Sections will give you the sections (which is a Page) below that given page section. This is only relevant for the home page and the section pages.
.Site.Home; .Site.Sections (which today is a taxonomy) is now deprecated, and to easily get to the top level sections I have added Home, so you can then do for range .Site.Home.Sections, .Site.Home.RelPermalink etc. .Page.Parent will for a section navigate one level up. For the top level sections (e.g. “blog”), this will navigate to the home page.
.Page.CurrentNot happy with this name which returns a pointer to the section the page belongs to. .Section would be better, but that is taken.
The sections are now a node tree with regular pages as leaf nodes – the root being the home page.
So .Page.Parent = the parent node, a way to navigate from the leaf node up to the home page.
I’m not sure the .Page.Current very useful on its own (it is used by .Page.IsActive), but it is a way to navigate to the current section – and since it is a Go pointer you can do super-fast comparisons to other pages to check if it is the same (hence. the IsActive usage).
First of all, this is a huge feature that many have asked about in the past. Thanks for trying to tackle it.
@budparr hinted at this (I think), but .Page.Parent is a better name than .Page.Current. Every node (whether branch/section or leaf/page) should support a .Parent call, I think. Are you saying that s1ss1p1.Parent = *s1ss1 would not work?
But you’re right, the IsActive name is not very descriptive. What about InSection or BelongsTo?
LOL. That’s essentially how we name our network equipment at work. Building+IDF#+Role+Device#. It’s handy because I can simply look at a switch name (like sm1as2) and know exactly where that device is on our campus.