Section list with titles, ordered by weight, plus subsections

I added _index.md files to my sections, including titles and weights. How do I create a list of all sections with the titles being displayed instead of the section slug/folder name?

When I make a list like this: {{ range $section, $taxonomy := .Site.Sections }}, I won’t have access to the variables set in the front matter.

1 Like

Let me expand on this. I have the following directory structure.

content
|_ section1
  |_ _index.md
  |_ subsection1
    |_ _index.md
    |_ post1.md
    |_ post2.md
  |_ subsection2
    |_ _index.md
    |_ post1.md
|_ section2
  |_ _index.md
etc.

Now I want to render a menu that lists the section titles ordered by weight, the underlying subsections (types) ordered by weight and the posts of the subsections.

<ul>
  <li>
    Section 1
    <ul>
      <li>
        Subsection 1
        <ul>
            <li>Post 1</li>
            <li>Post 2</li>
        </ul>
      </li>
      <li>
        Subsection 1
        <ul>
            <li>Post 1</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>
    Section 2
    <ul>...</ul>
  </li>
</ul>