Hi,
I have this content structure.
├── _index.md
├── about.md
├── cheatsheets
│ ├── _index.md
│ ├── git
│ │ ├── _index.md
│ │ ├── articles.md
│ │ ├── sites.md
│ │ └── snippets
│ │ ├── _index.md
│ │ └── change-commit-date.md
│ ├── html
│ │ ├── _index.md
│ │ └── articles.md
│ ├── latex
│ │ ├── _index.md
│ │ └── articles.md
│ ├── perl
│ │ ├── _index.md
│ │ ├── articles.md
│ │ └── sites.md
│ ├── python
│ │ ├── _index.md
│ │ ├── articles.md
│ │ ├── modules.md
│ │ ├── sites.md
│ │ └── snippets
│ │ ├── _index.md
│ │ ├── mock-python-version.md
│ │ ├── padding-numbers.md
│ │ └── qr-code.md
│ └── sphinx
│ ├── _index.md
│ └── articles.md
└── post
I am interested in cheatsheets
only
I have the following code in my layouts/cheatsheets
{{ with .Site.GetPage "/cheatsheets/" }}
{{ range .Sections}}
<h1 class="f1">
<a href="{{ .Permalink }}" class="link black dim">{{ .Title }}</a>
</h1>
<ul>
{{ range .RegularPages }}
<section class="mt5">
<h2 class="f2 mypadding">
<li>
<a href="{{ .Permalink }}" class="link black dim">
{{ .Title }}
</a>
</li>
</h2>
{{ .Content }}
</section>
{{ end }}
<!--- Create path for snippets from here --->
{{ $path := path.Join (path.Dir .CurrentSection) "snippets" }}
{{ $path = strings.TrimPrefix "Page(" $path }}
{{ $path = printf "%s/" $path }}
{{ with .Site.GetPage $path }}
<section class="mt5">
<h2 class="f2 mypadding">
<li>
Snippets
</li>
</h2>
<ul>
{{ range .RegularPages }}
<li>
<a href="{{ .Permalink }}">
{{ .Description }}
</a>
</li>
{{ end }}
</ul>
</section>
{{ end }}
</ul>
{{ end }}
{{ end }}
What it does is range over the sections under cheatsheets. Gets each regular page and their contents.
It then ranges over the sub-section named snippets
and instead of getting their contents it just gives links to the their individual pages.
I have tried the .RegularPagesRecursive
but I was not happy with the results, probably because I have never used it before. And to be honest, I am quite new to Hugo itself.
Question 1
Is this a good approach? Or is there a better option?
Question2
If I use a .Permalink on Snippets. It does not show a list of snippets pages. Rather is shows the parent sections. Do I need to create a snippets/list.html in my layouts? I could test it of course. But I really want an answer to question 1.