Table of Content (TOC) from several .md files

I try to set up a website using the techdoc theme because I want it to show documentation. This documentation is in 2 languages (possibly, but unlikely, more in the future).
I use the “same directory with language ending” option.

Since our documentations tends to be on the longer side, I want to have several .md files for the content. The folder structure is:

  • /content
    • /productA
      • /installation
        • /chapters

the _index.en.md is in /installation/ with what you could call meta information and legalize, while the documentation itself is in several parts in /chapters as chapter1.en.md and so on (basically a chapter per highest level header).

That way the user can click on the “Installation” line in the side menu and see the chapters like with those example folders from the theme:

I figured out how to automatically put a TOC into one of the chapters thanks to a forum thread here. But what I want to have is a TOC for all the chapters. (Either in the index or a chapter on it’s own.)

Means if I had a chapter0.en.md in the /chapters/ folder, how could I have a TOC in there with the content and links to chapter1.en.md, chapter2.en.md, chapter3.en.md, … ?

Aside question:

I am not sure if I understand the leaf and branch bundle correctly or if it is maybe the theme.

Normally I would have used an index.md (/installation/index.md) not an _index.md to access e.g. pictures from an subfolder
in /installation/images/ because that does not work with _index.md (only same level)

But if I do that, I can no longer see the chapters, in the example structure there would be no open/close button at Chapter 3-2 and the chapter 3-2-1 etc. would not appear.

Did I understand something wrong or what is it? Can this be solved?

Use an _index.md file to tell Hugo, “This directory is a section (branch bundle) that (probably) has member pages or subsections.” Use an index.md file to tell Hugo, “This is a just a page (leaf bundle), and it has no descendants.”

Do not choose one over the other based on where you want to place page resources.

Regarding your original question (TOC for a section), range over the member pages, then range over the .Fragments within each page.

1 Like

Use an _index.md file to tell Hugo, “This directory is a section (branch bundle) that (probably) has member pages or subsections.” Use an index.md file to tell Hugo, “This is a just a page (leaf bundle), and it has no descendants.”

That’s the part I don’t understand.

If I use an _index.md, the page does not find the pictures in the subfolder “images”.
If I rename it into index.md, the pictures in the images subfolder are displayed does.

As far as I understand it, it should be the other way round.


TOC:
“Range” is basically a loop?
So: range “/folder/” .Fragments ?

No. _index.md says: I’m a section, there are other folders with content below me
index.md says: There’s no more content coming.
Images are not content in this context.
Also: _index.md is for the list template, index.md for the single template

I suggest you read the parts of the Hugo documentation that are relevant for this. The range statement is one of the best documented ones, together with where. There’s no point in repeating the documentation here.