Apparently this is not an “enhancement” but a “discussion topic” so I’m re-posting it here:
In the 0.18.0 update .Site.Pages was changed to also include other types of pages (sections, taxonomies etc).
Then .Site.RegularPages was added in order to support the old behaviour which now requires a where .Site.Pages "Kind" "page".
Now this change affected .Paginator in the same way, if you have a site that uses the paginator to split a section in multiple pages now you will also see other “kinds” of nodes instead of what happened previously. So if you want to restore the old behaviour you will have to do:
Now i reread that i might have come across as a little bit more blunt than i intended apologies for that.
Secondly your solution is admittedly a lot cleaner than mine but you still have to create that global $paginator variable so a solution where that would be implicit would be even cleaner .
Lastly I don’t see why .Site can have it but .Paginate cannot (especially when the .Paginate.Pages shorthand does exist).
Now that i think about it, your solution does something different right? {{ $paginator := .Paginate .RegularPages}} will contain all pages on the site whereas {{ $paginator := .Paginate (where .Data.Pages "Kind" "page") }} will only contain the pages relevant to the current page (current Taxonomy). Although admittedly I don’t fully understand all of the recent changes so i might be wrong here.
I don’t understand at all, if I test any of this locally it seems to work but some of the behaviour does not match what it used to do in Hugo 0.17.0.
if any of my sections contain an index.md the paginator displays this but the url for the index page is the same as the url for the list. My initial expectation was that the index.md of a section was of the newly created “section” kind. However i just tested this with:
{{ range .Data.Pages }}
{{ .Kind }}
{{ end }}
And it only showed “page” for every md file in the section.
The reason I have this strange structure happened is because i have an about page structured like this: content/about/index.md. In Hugo 0.17.0 visiting /about/ would just shows single.html in Hugo 0.18.0 it shows list.html with one item that has the same url (/about/) and therefore cannot be opened.
I guess I’ll stick to Hugo 0.17.0 for now because i don’t even understand how the new “home” and “section” kinds work and my pagination contains these broken pages that i have no idea how to filter out.
In Hugo 0.18 everything became a page, even nodes. To make them distinguishable, each page is of a certain kind, i.e. a page is of kind section (which was formerly be a node).
You could filter them out by checking the .Kind attribute and use only those kind of pages you really want to use. But as @bep suggested, use .RegularPages because this list only contains “real” pages, i.e. those page you know as pages from previous Hugo versions.
.Data.Pages and its alias .Pages contains the contextual pages that belong to a given list page. For the home page, that list will contain every page except itself (including regular pages, taxonomy lists etc.). The same list on a section page will only contain regular pages that belongs in that section.
The .Pages collection on the paginator object is, by default, based on the above. You can change that by passing a custom collection to it (.RegularPages or one created with where). It doesn’t make sense, nor is is it possible, to add a paginator.RegularPages, as it will only be one for a given page: .Pages holds the pages (default 10) for the current pager, and the pages can be regular or whatever, but it can only be one collection.
I understand this but expected the other kinds of pages to also receive data from markdown files in the content folder which is not the case, only pages of type “page” seem to have a markdown data associated with them.
Reading issue 2240, 720 and 330 (cant link directly) gave me the idea that content/index.md would be of kind “home” and provide layouts/index.html with its data. I also assumed that these pages should now be filtered out of the paginator which doesn’t seem to be the case. I still do not understand how the changes made in Hugo 0.18.0 allow us to designate a page as “section” or “home” or how to use/access these kinds of pages from a layout.
Say I want an “about me” section on my homepage that is authored in markdown how would i create the markdown file containing this information and how should layouts/index.html access this? I assume it involves .Site.GetPage but can’t find a clear explanation.
Additionally Hugo seems to have trouble figuring out how to display a index.md file inside a section. For sections that did not contain any other markdown files Hugo used to just render single.html for that section however now it appears to render list.html with one item who’s .Permalink is the same as the list page. This confused me further as i assumed this might be an example of a page of kind section but I was wrong.