I’ve been building a theme for my blog and it has been a delight so far. I love how Hugo has just the right balance between complexity and usefulness. I’ve been trying for a few days now to solve the following problem but to no avail.
Is it possible to Paginate ALL the pages within a folder, including all the files within subdirectories, and not just the files directly insider this folder?
Since the taxonomies in Hugo are flat I’ve a nested file structure (I’m anal about organization) which I then loop through, for instance, for producing menus. Currently I’ve the following directory structure
posts
+Books
++ Post_1.md
++ Post_2.md
++ Book_1
+++ Post_3.md
+++ Post_4.md
++ Book_2
+++ Post_5.md
+++ Post_6.md
I’m trying the following code (inside list.html). This is the entire list.html, there are no other lines.
{{$.Scratch.Add "list_pages" .Pages}}
{{ range .Sections }}
{{$.Scratch.Add "list_pages" .Pages}}
{{ end }}
{{$paginate := .Paginate ($.Scratch.Get "list_pages")}}
However here I get the error:
ERROR 2017/12/30 11:51:21 Error while rendering "home": template: theme/_default/list.html:12:15: executing "theme/_default/list.html" at <.Paginate>: error calling Paginate: invoked multiple times with different arguments
Upon searching the discussion boards I THINK this is happening because I’m calling .Pages which is somehow setting the $paginate (which I understand is static). So I guess the bottomline is:
Is it possible to get the list of pages without setting $paginate? Or is it the case that $paginate is preset in some sense and it cannot be used to Paginate user-defined arrays?
Thanks,