Hello, there’s something I don’t get with section calls.
I have
/content
../first-branch
..../child-of-first-branch
if i do
{{ $firstBranch := where .Data.Pages "Section" "first-branch" }}
it’ok page=X
if if do
{{ $child-of-first-branch := where .Data.Pages "Section" "child-of-first-branch" }}
not ok page=0
all have _index.md
What i have missed to call subsection ?
bep
October 29, 2019, 4:06pm
2
I think you will find it easier to work with the built-in methods, e.g.:
{{ $first := .Site.GetPage "first-branch" }}
{{ $children := $first.Pages }} // Pages and sections
{{ $sections : = $first.Sections }} // Sections only
With the above and related methods you can recurse down the tree.
ok so
{{ $child-of-first-branch := .Site.GetPage "Section" "first-branch/child-of-first-branch" }}
and if i want to range
{{ range last 3 $child-of-first-branch.Pages }}
Thank you master @bep
bep
October 30, 2019, 5:16pm
4
I guess the above also works, but this is simpler:
{{ $child-of-first-branch := .Site.GetPage “first-branch/child-of-first-branch” }}
If you have a look at the docs, there are lots of useful section related methods.