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?
I have tried to wrap my head around your Germany in the 40s name standard, and it is mostly correct.
Your IsActive examples may be correct, but does not make much sense. The typical pair would be a section and a regular page.
s1ss1p1.Parent = *s1
And you cannot currently rename Current to Parent … they are two different entities. I agree that “Parent” may be confusing, as it is currently really “ParentSection”.
So, after thinking about this here is the proposed change:
Remove Current (or unexport it)
Make Parent so it always takes you one step up the tree
I think I misunderstood what IsActive was doing. I thought you were trying to see if two pages were in the same section. In that case, IsPeer makes sense.
However, IsActive tests if a page belongs to a section.
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.