Custom Sidebar Nav Overrides
mitchnemirov opened this issue · comments
Is your feature request related to a problem? Please describe.
The current sidebar will always create collapse menus for pages with children, and there is no way to override this behavior to have an "always-expanded" list of pages/sub-pages.
Describe the solution you'd like
Support for custom_sidebar or custom_nav includes built into the theme to simplify modifying site navigation without having to copy-paste the entire source file to make changes.
That, or add a config option to enable or disable collapsed sections in the sidebar, either per parent-page or site-wide.
Describe alternatives you've considered
What I'll do in the short-term is modify the theme's nav.html and add it to my _includes folder to do a manual override of sorts.
Just discovered the Collections feature and realized I should read more prior to opening up feature requests! Problem solved / not a problem to begin with!
Thanks for submitting an issue @mitchnemirov, and glad you were able to resolve it! Just to check in - could we have had more clear documentation on how to do this? Perhaps still a learning moment for us!
Hi @mattxwang! I think the collections documentation is just a bit out of the way. Maybe moving it to the Customization or Navigation section could make it stand out more, or even just referring to it with a link from those pages when discussing custom navigation options/layouts.
I'm a bit busy at the moment but when I find some time I could potentially submit a PR with some documentation updates.
Thanks for the response @mitchnemirov; a PR is certainly welcome, and no rush (open-source has no deadlines). Happy to review once you're ready!
@mitchnemirov @mattxwang I am trying to automatically expand some of the parents in the navigation structure but cannot find the way how to. How did you manage to default expand the toc children? From the docs the only option that makes sense is nav_fold: false but this does not work.
For instance how to set UI Components to be default open here:
@eoudejans
I tried to document this a bit more clearly and submitted a PR #1390 to update the docs, but basically you'll want to use the Document Collections feature and set the following in your config.
_config.yml:
collections:
collection-one:
permalink: "/:collection/:path/"
output: true
collection-two:
permalink: "/:collection/:path/"
output: true
just_the_docs:
collections:
collection-one:
name: Collection One
nav_fold: false
nav_exclude: false
collection-two:
name: Collection Two
nav_fold: false
nav_exclude: false
In your site directory:
_collection-one/page1
_collection-one/page2
_collection-two/page3
etc.
Obviously name the collections whatever you want, just make sure the directory name starts with an underscore(_) or it won't work. All your sub-pages just live within each "parent" directory.
This will remove the ability to collapse the top-level "parent", but it is then fully-expanded all the time. See below for example:
This also removes the need for a parent page, though if you require a parent page I'm not sure this is what you want.
Thank you so much for your detailed and answer and fast response. I will try this out and I think this will work.