Given the following structure of the content folder:
- blog
├─ 2019
├─ myoldposts
| ├─ 2008
| └─ 2009
└─ shares
├─ 2019
└─ migrated
├─ 2014
└─ 2015
How can I list pages only from shares
plus subdirectories?
I can use
range (where .Pages ".File.Dir" "in" "blog/shares/migrated/2014/")
to filter for the lowest subdirectory.
But when I try to go one level up it doesn’t work anymore:
range (where .Pages ".File.Dir" "in" "blog/shares/migrated/")
Using comparators like ge
doesn’t work either.
Is there no function that checks for a substring?
Similar problems that got solved in other ways:
Have a look also in this thread:
Consider the following directory structure in the root directory of a hugo static site:
content
|
└── A
└──A1
├── a.md
└── b.md
└──A2
├── a.md
└── b.md
└──A3
├── a.md
└── b.md
.
.
.
All I want to do is render the ‘Content’ of the markdown files; but I want to do this directory-wise i.e., I want a separate row for all the sub-directories viz. A1, A2,… and inside each row, I want the content of the…
Merci. As far as I can see that post tackles a similar issue. Difference seems to be that I don’t want posts grouped by subfolder. I want them all listed in the blog but also have a page where I list a subset.
So the question is: How do I get an array of all the posts stored below a specific folder.
Another thing I’ve played around with is findRE
. Unfortunately I can’t get it to work in where
either:
Because findRE
is not a valid operator in where
I can’t do:
{{ $posts := where .Pages ".FileDir" "findRE" $path }}
And this doesn’t work because “.FileDir” is treated as a string:
{{ $posts := where .Pages (len (findRE $path ".FileDir")) "gt" 0 }}