Loop over siblings of the section

I have the following structure:

content/
├── portfolio/  <-- section (top-level directory)
│        ├  _index.md   
│        ├── portfolio-one/
│        │          ├── _index.md   
│        │          ├── item-1/
│        │          │        └── index.md
│        │          └── item-2/
│        │                     └── index.md
│        └── portfolio-two/                     <--- I am here for example
│                    ├── _index.md   
│                    ├── item-3/
│                    │        └── index.md
│                    ├── item-4/
│                    │        └── index.md
│                    ├── item-5/
│                              ├── _index.md
│                              ├── item-5-part-1/
│                              │          └── index.md
│                              ├── item-5-part-2/
│                                          └── index.md

…and want to get a list of all _index.md siblings on the same level without Childs and Parents, for example

i am here in portfolio-two and want so get a list with:

portfolio-one/
portfolio-three/ 
and so on

which excluded portfolio-two itself.

Same for every level in looking in.

I have searched the forum, and here , wrapped my brain around it but couldnt get it work.

any help is welcome as always :slight_smile:

best regards carsten

I would think of:

  • get the parent of the current page .Parent
  • get all sections of that parent .Parent.Sections
  • wrap the current page into a collection (slice $))
  • filter the current page from all sections using complement

need to wrap the current page as slice for complement

{{ range (complement (slice $) $.Parent.Sections) }}
<h3>{{.Title}}</h3>
{{ end }}
1 Like

That was a perfect guess. Works like a charm.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.