Disable category/section/index pages, but keep sections present in navigation

Hey there. I’m trying to figure out if it’s possible to organize pages under a section but have the section header really only used for expanding the section on the menu.

More concretely, suppose I have the following site layout:

└── content
    └── posts
    |   ├── _index.md
    |   ├── post-one.md
    |   └── post-two.md
    └── articles
        ├── _index.md
        ├── article-one.md
        └── article-two.md

What I would like is for my navigation menu to still show “Posts” and “Articles,” and expand to show their subpages when possible. However, I would like for the “Posts” and “Articles” entries in the menu to not redirect anywhere.

I did find these _index.md Build Options when searching for similar topics:

  render: never
  list: never

When I set this it removes the section from the navigation entirely, rather than making the section header just used for expanding that section of the menu. Is there a way to accomplish this?

Are you creating the section menu by ranging over site.Menus.xxx, or are you recursively walking the sections? The latter is scalable (just create a new page) and less error-prone.

1 Like

I’m using the “Learn” theme, and it looks like it is just iterating over .Site.Home.Sections here. I suppose the solution is to create my own menu.html partial to overwrite this behavior then, right? It seems like each <ul> under a section is set to display: none; if the section is not selected, and display: block; if it is selected. Would the solution here be to make each section header toggle the visibility of its <ul> child rather than redirecting to /section?


Sounds right, but will depend on the theme template, your JS/CSS, etc.

Cool, thanks for the confirmation. I appreciate it.

If you are displaying post-one, would you expect the breadcrumb to include posts without a link?

I’m not 100% sure what you’re asking… if I was looking at post-one I would expect the full URL to be /posts/post-one, but just that /posts itself doesn’t really point to anything.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.