Sort for specific posts on subdirectorys?

Hello,
the project i am working on is pretty advanced for Hugo, i think. My Goal is to import specific posts in a specific html file:

current structure:
content/
├── _index.md
└── services
├── _index.md
└── post/
└── firstpost.md
└── secondpost.md
layouts/
├── index.html
└── services
└── list.html

so I wanted to import a summary of posts on the list.html file. I found different methods to import the posts but no function for sorting works for me.

These are my two methods I am working on right now:

  1. Sorting by directory:
    {{ range (readDir “content/services/post”) }}
    {{ $page_name := .Name }}
    {{ $page_directory := (print “content/services/post/” $page_name)}}

     {{ $page_name }}
     {{ $page_directory }}
    

    {{ end }}

The problem on this is, that i can’t get the .Dir variable to compare it.

  1. Sorting via variables
    {{ range $.Site.RegularPages }}
    {{ $posttype := .Params.posttype }}
    {{ $posttype_services := “services” }}

     {{ $posttype }}
     {{ $posttype_services }}
    

    {{ end }}`

But on this I’ll always get an error when i try to {{ if (eq $posttype "services") }}, i think the variable created by range, can’t be used inside a if statement?

I am not very familiar with hugo, so I hope you pros can help me. :stuck_out_tongue:

Regards
OjunbamO