`.Pages` including first-level section pages under the current list page?

Hi there! I recently migrated from hugo 0.58.3 to 0.77.0
In my Hugo Website, I have a /blog section, and I list all pages in that section with “.Pages”.
Some pages in the blog are “section page” (a directory with a files and subdirectories containing each file)

|   |__
|___ /post2
|    |__
    |__ /post1
    |   |__
    |__ /post2
    |   |__

with Hugo 0.58, the .Pages method in the blog list template returned me the subsection page with the leaf pages, wich was very convenient for me, as I wanted to list this subsection as an element of the blog (but not the subsection children).

but now with 0.77.0, .Pages does not return the subsection anymore. I did not get it neither with .RegularPages, and I dont want to list all subsection pages using .RegularPagesRecursive, I only want an entry in the blog for the subsection.

I tried to add a frontmatter in the subsection, telling to list this page

  render: always
  list: always
  publishResources: true

But no success

The documentation says:


Collection of regular pages and only first-level section pages under the current list page.

Seems like this is not true anymore. Is there something I’m missing ? What would be the correct way to do? If You need it my repo is here:

The subsection with other pages is content/blog/2020/Municipales 2020 - Analyse des réponses des candidats/

Your site produces errors when I try to build it.

git clone
cd pauavelo-website
hugo server

Start building sites …
ERROR 2020/11/20 15:23:09 render of “page” failed: execute of template failed: template: _default/single.html:24:6: executing “main” at <partial “single/related.html” .>: error calling partial: execute of template failed: template: partials/single/related.html:16:15: executing “partials/single/related.html” at <partialCached “cards/generic.html” (dict “display_summary” false “page” .) .Permalink “false”>: error calling partialCached: execute of template failed: template: partials/cards/generic.html:8:4: executing “partials/cards/generic.html” at <partialCached “cards/image.html” .page .page.Permalink>: error calling partialCached: “/home/jmooring/temp/pauavelo-website/layouts/partials/cards/image.html:2:16”: execute of template failed: template: partials/cards/image.html:2:16: executing “partials/cards/image.html” at <.Fit>: error calling Fit: image “/home/jmooring/temp/pauavelo-website/content/blog/2018/Faites du vélo 2018 à Pau/header.png”: fit : image: unknown format

I am unable to reproduce the problem you describe. Try this:

git clone --single-branch -b hugo-forum-topic-29540 hugo-forum-topic-29540
cd hugo-forum-topic-29540
hugo server

Then visit http://localhost:1313/blog/

Hi, thank you for your reply. My repo is using git-lfs, as it has a lot of large files. So it needs git-lfs to be installed on your machine, or it will have pointer files instead of images, and that causes error during image processing.

This is how you can reproduce my problem, based on the repo you proposed on githbub:
Put a “2020” directory under the blog directory, and here inside this “2020” directory, you move your content files and subsection.
if you go to http://localhost:1313/blog/
It will show your content without the subsection (ok I understand now, it was not a “first level” section)
But if you go to http://localhots:1313/blog/2020/
it shows nothing (neither content leafs, nor subsection)

Create /content/blog/2020/ and try again.

I’ve updated the test repo.

You’re right, with an file in /content/blog/2020/, it works as expected in the docs. However it does not fit my needs: I want http://localhost:1313/blog to list all the post and 1st level subsection of all the years (2018, 2019,2020…), and that’s why I did not put an in the 2020 directory.

Maybe I should have an for each year, and write a specific template for /blog, that ranges every years and inside each one of them ranges every post and subsections ?

My implemented solution, if it helps somebody: I list all pages that have “blog” as direct parent. I do this by matching the permalink of the parent. Here is the corresponding code in my list template

// layouts/_default/list.html

{{ $pages:= .Pages }}
{{ if eq .RelPermalink "/blog/" /*we want to list blog's direct children*/}}
{{ /*list all items that are direct children of "blog", 
    whether they are "leaf"(post) or "branch" (list of posts), even if
    thoose direct childs are in subdirectories */
  {{ $pages = where (where .Site.Pages "Section" "blog") ".Parent.RelPermalink" "/blog/" }}
{{ end }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
{{ end }}