Best way to show an arbitrary nav tree on the homepage? #7252
-
Hi Everyone! I would like my homepage to display the standard left-column navigation tree with a sub-section of my site nav. The challenge is my home page is not part of the tree itself. For example:
By default, the left hand nav on the homepage is blank, since the home page is not in the nav. No prob. But I want to show the nav at the "My Guide" level on my homepage. I'm wondering if someone can point me in the right direction as a starting point? For example, should I make an I'm confident I can figure out how to actually make it happen, but it seems like there are several ways to approach this, so I wonder if someone has an opinion on what's the cleanest or most elegant way to approach this? (Worst case I just manually add it to the template, which would work but then I'd have to maintain the TOC in two places.) Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hello @toomanybrians, Firstly, I would abstain from modifying the The quickest option to get it sorted would be to use a custom
If you're using the |
Beta Was this translation helpful? Give feedback.
-
I have a follow up question for this. I'm taking the route of a I can't figure out the CSS though. If I just copy the exact HTML code that's usually generated, my sidebar works fine, but then on mobile devices the hambuger menu shows my custom content sidebar content, rather than the "real" site nav from the header. I tried lots of different options with CSS classes and structure, but it looks like I'm missing something. I see that the top header site nav and sidebar site nav are sort of mingled together in the HTML, with ceratin "active" class names which trigger what's actually showing. So I think I'm on the right path but can't completely figure it out. I wonder if someone who knows more about the way the menu and CSS works could give me some hints? Thanks! |
Beta Was this translation helpful? Give feedback.
Hello @toomanybrians,
the navigation on the left hand side should be visible even though the
index.md
isn't included 🤔Perhaps you're using
navigation.tabs
which changes the rendering of navigation and sort of detaches it.Firstly, I would abstain from modifying the
nav
either in the mkdocs.yml or via hooks to duplicate entries, as this would lead to bugs.The quickest option to get it sorted would be to use a custom
home.html
template with a static HTML structure written in thesite_nav
block.mkdocs-material/src/templates/base.…