Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Multi-level sections (tree) #465
@spf13 Sorry in advance if you find this too long or absurd (or both).
This requests is based heavily on personal needs. I am struggling with this problem from long time. So I decided today to post this down in as much details as possible.
I came across few threads in same direction suggesting to make use of front-matters. I will explain why I think front-matters is not an optimal choice here.
I have created a sample site to explain this problem - https://github.com/rahul286/hugo-sample
Content looks like:
As you can see there many levels at which directories and content are present.
What I am trying to have is...
For any folder, list down pages at immediate levels only OR at all levels.
If listing at all-levels, nested lists should be created. Something like list of pages shows on - http://rtcamp.com/tutorials/
As you can see for sample-site - http://rahul286.com/hugo-sample/level-one/ shows all pages but without any hierarchy.
At sub-levels nothing shows up: (bigger problem)
But direct link to inner-page still works - http://rahul286.com/hugo-sample/level-one/level-two/level-three/level-four/page-4-b/
This means directory structure is preserved. Just nested directories do not have an automatically generated index page.
Hugo did generate index page for top-level folder automatically as it appears - http://rahul286.com/hugo-sample/level-one/ (source - https://github.com/rahul286/hugo-sample/blob/gh-pages/level-one/index.html )
I think hugo has few things already in-place which generated level-one index page.
Few changes/enhancements will be needed so hugo can be used on sites with multi-level pages.
I think first task will be easier (sorry if I am underestimating this, as I'm new to golang)
Second task can get tricky as different sites may wish to control list pages html differently.
At code-level, hugo may extend...
referenced this issue
Oct 19, 2014
I've made a small change here:
That at least gives an index page at each level of content. With .Data.Pages containing just the list of the current level. The list template may be provided at
This is satisfactory for my needs, I'll try to take a deeper look and create a proper pull request.
@pedromorgan After trying to implement this feature as mentioned last week, I found in the code a hidden feature in hugo with categories. If you create categories like the following:
hugo will create index on all those levels (and pagination works if you enable it). That's an alternative to patch from @baruchlubinsky . Categories, you can fix them in the template. The only problem you end up using /categories/ ... unless you move the content manually using a script to main and replace /categories/ everywhere.
Note: my content is auto generated and not manually by hand.
changed the title from
Multi-level nested pages handling [feature-request]
Multi-level sections (tree)
Feb 27, 2017
referenced this issue
Mar 4, 2017
The more important thing is simply to support subsections with their own
In other words, Which Template will be rendered? would be updated as follows. My additions are in bold, and ideally could be expressed in a simpler way for the documentation.
@tryjigs using taxonomy for hierarchical structuring is the best solution here.
In my opinion subsections is pretty straightforward implementation, but it has no flexibility comparing to hierarchical terms in taxonomy.
And I have a question about current "hierarchical terms in taxonomy" state:
I did it by using a big monstrous trick (so don't blame about code) that you can find here https://github.com/kakawait/hugo-tranquilpeak-theme/tree/master/layouts/partials/internal and result https://tranquilpeak.kakawait.com/categories/
I'd just like to add an addendum to this: when Hugo gets multi-level support, I'd like to be able to have one template for when I want to list subsections, and one template for when I want to display/list actual content/summaries of content.
My suggestion would be to make a new reserved template, called
The idea behind this being that if I have 10
This way, you'd only need two template files to have a structure like so, with listings at each level: