Exclude main pages from range and paginate

I am not overly familiar with git or GitHub at this point, but I have attempted to add my files to a repo for the sake of this post: GitHub - thejollyfrog/vg2
(apologies if I have done this incorrectly).

I am a graphic designer with some code knowledge and theme building experience in Ghost. I am using Hugo (0.83.1) on Manjaro Linux.

I have only been learning Hugo for a week, but I have successfully completed a Hugo rebuild of the following website: veggieguide.co.uk (a ghost website which I built) aside from one thing: excluding pages from the index page when using range.

What I have tried:

{{ range .Paginator.Pages }} successfully loops through my posts, with pagination, but includes pages I wish to leave out which are not in the “blog” directory.

{{ range (where .Site.RegularPages “Type” “blog” )}} successfully displays the blog pages without the excluded pages (which are not in the “blog” directory), but all blog posts (50) are displayed on the page.

I have read and reread the documentation, but my comprehension of it is obviously lacking. I have attempted to use the suggested code (slightly adapted) with no luck:

{{ $paginator := .Paginate (where .Pages “Type” “blog”) }}
{{ template “_internal/pagination.html” . }}
{{ range $paginator.Pages }}

In this case, I get one post with the name “Blogs”?. When clicked, the post leads to a blank page.

What did I expect?

I was hoping that pages such as the about page, contact page etc. could be excluded from the range.

I love Hugo, it has been fun to work with, and I plan to document the process of building a theme from scratch for others who may benefit.

I have done my best to research this issue and found similar issues, but I was unable to find a usable solution for my specific issue.

Your guide stated to start a new issue rather than resurrect an old one.

My content structure is as follows:

 content
  - blog
    - postname1
      - index.md
    - postname2
      - index.md
    - postname3
      - index.md
  - pagename1
    - index.md
Any help on this would be very much appreciated.

you need a more extended where clause …

compare my sample line 20

You can create your own pagination template too

Thank you @ju52. I am looking at your code trying to decipher how it works and, unfortunately, I think I am just not there at this point.

I have been reading the Hugo documentation on range, where and pagination; plus going through the docs from the beginning (Templating introduction), but I think it may take me quite a while before the penny drops and I become fluent.

I’d love to be able to solve this one myself, but this last puzzle appears to have me stumped.


EDIT/UPDATE!

Staring at your code some more and doing some experimentation, I seem to have sorted it. Nothing seems to have broken, the home page seems to be exclusively showing my blog posts and the pagination seems to be working. Could you confirm if this is the/a correct way of achieving pagination while ranging over only blog posts please?

{{ $paginator := .Paginate (where site.RegularPages “Section” “blog”) }}
{{ range $paginator.Pages }}

looks right,

but you get this per default with list template for blog section