Get param of file in readdir


I want to list file in directory and get param of this file to make a thumbnail of description and main image


I have some issue to get param of file in directory

I write this code

      {{- $files := readDir "content" -}}
        {{- range $files }}
        {{- with .GetPage $.Name }}{{ .Param "description" }}{{end}}
        {{ end }}

And I get the following error

executing "index.html" at <.GetPage>: can't evaluate field GetPage in type os.FileInfo

Can you help me ?

I think you will make it simpler for you if you had a look at Hugo’s built in page collections:


{{ range site.RegularPages }}
{{ .Description }}
{{ end }}

There are a set of related methods that should cover most needs.