Displaying list of markdown files in specific folder


I would like to render a specific list of .md files in a partial.

The files are organized like so :

In each offer1.md, offer2.md, I have a frontmatter section with the values I would like to access in my partial:

  • title : Offer 1
  • description : Description 1
  • price : Price 1

The site is multilingual, so the folder name differs between the FR and EN version (offres vs offers).

Of course, I only want to display the pages of the current language.

What would be the correct syntax in my template to manage this ?


To cut a long story short:

  1. I suggest that you normalize the section names to a common language, e.g. offers (you can set title and posibly also URL if you want in front matter per language)
  2. With that you can do:

{{ $section := site.GetPage “offers” }}
{{ range $section.Pages }}
{{ .Title }}
{{ end }}
{{ end }}


{{ $section := site.GetPage “offers” }}
{{ range $section.RegularPages }}
// …
{{ end }}
{{ end }}

Thank you @bep, I went with the first solution which works perfectly.

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