Can't get entries in bundled pages to show up in menu

Content Structure A:

content/
    page1.md
    page2/
        index.md
        page3.md

Content Structure B:

content/
    page1.md
    page2.md
    page2/
        page3.md

My menu code:

<ul>
  {{ $currentPage := . }}
  {{ range .Site.Menus.docs }}
  <li class="{{if or ($currentPage.IsMenuCurrent "docs" .) ($currentPage.HasMenuCurrent "docs" .) }}menu-active{{end}}">
    <a href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a>
      {{ if .HasChildren }}
      <ul>
        {{ range .Children }}
        <li class="{{if ($currentPage.IsMenuCurrent "docs" .)}}menu-active{{end}}">
          <a href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a>
        </li>
        {{ end }}
      </ul>
      {{ end }}
  </li>
  {{ end }}
</ul>

page3.md frontmatter:

---
title: "Page3"
menu:
  docs:
    title: "Page3"
    weight: 10
    parent: "Page2"
---

I can only get the menu working as intended (showing sub menus of child pages) with content structure B. But isn’t this incorrect?

Been trying to figure this out with the docs for the past hour. Help is needed.

That looks like a leaf bundle with a resource (page3.md) of type page. According to the docs:

Permalink
The absolute URL to the resource. Resources of type page will have no value.

So you can’t actually link to it (or have a menu item for it).

Could you use a branch bundle structure instead? (i.e. with _index.md )

2 Likes

Could you use a branch bundle structure instead? (i.e. with _index.md )

Then /page2 doesn’t work.