Paginated items not going beyond default

I have an issue where custom paginated items do not go beyond the default one by Hugo (10). If I define, say first 5, five items show up. But if I do first 15, then the number is stuck at 10. I am not sure if it is due to my .Paginate code which I have at the head and list pages as follows.

Summary
<!-- head.html -->

{{- $paginator := "" -}}
  {{- if or (and (.IsSection) (eq .Params.sec "blog") ) -}} <!-- Params.sec "blog" here is a front matter variable added to the blog section's _index.md for default/translated pages -->
  {{- $p := slice -}}
    {{- range (where site.Pages "Type" "post").ByDate -}}
      {{- if or
        (and .IsPage (not (eq .Layout "multipage" )))
        (and .IsSection (eq .Layout "multipage" ))
      -}}
        {{- $p = $p | append . -}}
      {{- end }}
    {{- end -}}
  {{- $paginator = .Paginate ($p.ByDate.Reverse) -}}
  {{- end -}}
  {{- if or (.IsSection) ( and (.IsSection) (ne .Layout "multipage") ) -}}
  {{- $page := .Pages -}}
  {{- $paginator = .Paginate ($page.ByDate.Reverse) -}}
  {{- end -}}

 {{- if or (and (.IsSection) (eq .Params.sec "blog") ) ( and (.IsSection) (ne .Layout "multipage") ) -}}
  {{- if  (eq $paginator.PageNumber 1)  -}}
  <link rel="canonical" href="{{ .Permalink }}">
  {{ else }}
  <link rel="canonical" href="{{ .Permalink }}page/{{ $paginator.PageNumber }}/">
  {{ end }}
  {{- if $paginator.HasPrev -}}
  <link rel="prev" href="{{ .Paginator.Prev.URL }}">
  {{ end }}
  {{- if $paginator.HasNext -}}
  <link rel="next" href="{{ .Paginator.Next.URL }}">
  {{ end }}
  {{- end }}
Summary
<!-- list.html -->

{{- $page := slice -}}
    {{- if eq .Params.sec "blog" -}}
    {{- $p := slice -}}
    {{- range (where site.Pages "Type" "post").ByDate -}}
    {{- if or
    (and .IsPage (not (eq .Layout "multipage" )))
    (and .IsSection (eq .Layout "multipage" ))
    -}}
    {{- $page = $p | append . -}}
    {{- end -}}
    {{- end -}}
    {{ else }}
    {{- $page = .Pages }}
    {{- end }}
    {{- $paginator:= .Paginate ($page.ByDate.Reverse) -}}

I am wondering if there is a conflict between those two instances hence why the numbered items per page are not overriding the default. I am asking for help to diagnose this.

Set in config.toml below, just after baseURL

paginate = 15

and see if that change behaviour

That’s not the problem. I think I encountered the issue @jmooring described in this post because I am using an iteration of the multipage posts.

Edit: I just found a way around it. I set a higher number of pagination in the configuration file which applies to the custom layout(s). Then I added a limit (using first) to the default layout’s pagination sequence with a lower number.

Edit 2: I spoke too early! The first command skips posts that are the difference between the number set in the config and the first command. So, if paginate in config is 15 and first is 10, it skips 5 posts per page!

Edit 3: I followed the base layout in the example in Joe’s link. I split my header file code above into various conditions, then assigned the pagination integer for each.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.