This is a piece of working code.
{{ $wPosts := where .Site.RegularPages "Section" "advertisements" }}
{{ $w10 := first 10 $wPosts }}
{{ $wp01 := index $w10 3 }}
This is something not working
{{ $wPosts := where .Site.RegularPages "Section" "advertisements/copies" }}
{{ $w10 := first 10 $wPosts }}
{{ $wp01 := index $w10 4 }}
How can I pull posts from a subfolder inside a section folder?
If the “/advertisements/copies/” directory contains an _index.md file:
{{ $p := (site.GetPage "/advertisements/copies").Pages }}
If the “/advertisements/copies/” directory does not contain an _index.md file:
{{ $p := where site.RegularPages "Path" "like" `^/advertisements/copies/` }}
https://gohugo.io/functions/collections/where/#regular-expression-comparison
2 Likes
Thank you so much for the help. You saved my day. Despite trying various AI tools like ChatGPT, Copilot, and Gemini, I never consulted the official documentation.
system
Closed
September 21, 2024, 4:36pm
4
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.