Hello guys,
my plan is to show all posts under a specific sub-website called /posts there should be listed all posts from “content/posts/subdirectory/post1/_index.md”. The reason for the subdirectory is to have a knowledgebase more organized with “series”. I have a list which works fine for my Problem:
{{ range (where .Site.RegularPages "Section" "posts") }}
<a href="{{.Permalink}}">{{- .Title -}}</a>
{{ end }}
But if i use this list 1. i can’t view all pages of a specific subdirectory for example on the site: “content/posts/subdirectory/” and 2. my list-pagination to split the posts up is also broken.
If i just range the paginator pages only single posts will be displayed, so the subdirectory listing works fine but not for the /posts overview, there will be nothing:
{{ range .Paginator.Pages }}
Do you know any way to include websites of a sub-sub-directory to the pagination or know a workaround which also works with the pagination?
First thanks for you’re answer.
I tried to use .Paginate but it always results in an error.
summarized:
I just need to iterate over all pages in a specific subdirectory with .Paginate and list all posts of the “Sub-Sub directorys”.
First I was using {{ range .Paginator.Pages }} but on the /posts list section it showed nothing. For the list /posts/whateverseries it worked very well.
If I try to use your solution, it just says that RegularPagesRecursive isn’t existed like. Also not existend in the docs.
render of "section" failed: "layouts/_default/list.html:103:31": execute of template failed: template: _default/list.html:103:31: executing "main" at <"hub">: can't evaluate field RegularPagesRecursive in type page.Page
render of "section" failed: "layouts/_default/list.html:103:31": execute of template failed: template: _default/list.html:103:31: executing "main" at <"hub">: can't evaluate field RegularPagesRecursive in type page.Page
Rebuild failed:
Failed to render pages: render of "section" failed: "layouts/_default/list.html:103:31": execute of template failed: template: _default/list.html:103:31: executing "main" at <"hub">: can't evaluate field RegularPagesRecursive in type page.Page
and just {{ .Paginate.Pages }} says:
render of "section" failed: "layouts/_default/list.html:103:16": execute of template failed: template: _default/list.html:103:16: executing "main" at <.Paginate.Pages>: wrong number of args for Paginate: want at least 1 got 0
render of "section" failed: "layouts/_default/list.html:103:16": execute of template failed: template: _default/list.html:103:16: executing "main" at <.Paginate.Pages>: wrong number of args for Paginate: want at least 1 got 0
Rebuild failed:
Failed to render pages: render of "section" failed: "layouts/_default/list.html:103:16": execute of template failed: template: _default/list.html:103:16: executing "main" at <.Paginate.Pages>: wrong number of args for Paginate: want at least 1 got 0
{{ if in .Permalink "/posts/" }}
{{ range (where .Site.RegularPages "Section" "posts") }}
<a href="{{.Permalink}}">{{- .Title -}}</a>
{{ end }}
{{ else }}
{{ range .Paginator.Pages }}
<a href="{{.Permalink}}">{{- .Title -}}</a>
{{ end }}
{{ end }}
The only problem with this now, is that it’ll show all entries of /posts on all list series: /posts/whateverseries + the pagination won’t work (but I think thats tolerable)
Does anyone know how to build a little workaround for that? With an extended if statement or something?