Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent: error calling Paginate: cannot convert type page.PagesGroup to Pages #1461

Open
jgoerz opened this issue Mar 6, 2023 · 0 comments
Labels
blog bug Something isn't working e0-minutes Effort < 60 min e1-hours p2-medium p3-low
Milestone

Comments

@jgoerz
Copy link

jgoerz commented Mar 6, 2023

TL;DR
Deleting the cache file referenced in the error seems to make the error go away with (I believe) no ill effects.

My info:

$ hugo env
hugo v0.110.0+extended linux/amd64 BuildDate=unknown
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.19.5"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.2.4"

I created the site using hugo new site name-of-site and using hugo as a module. Once complete, I copied minimal content items from the mostly docs repository. Specifically, I used their content/en/_index.md frontmatter that is using the cascade feature.

When I build or try to run this site locally I get the error about every 2 out of 3 times building/running it. The error:

$ hugo serve
Start building sites … 
hugo v0.110.0+extended linux/amd64 BuildDate=unknown
Error: Error building site: failed to render pages: render of "section" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/google/docsy@v0.6.0/layouts/blog/list.html:11:13": execute of template failed: template: blog/list.html:11:13: executing "main" at <.Paginate>: error calling Paginate: cannot convert type page.PagesGroup to Pages
Built in 641 ms
$

This looks very close to issue #56 in the docsy-example repo and also similar to issue #52 in this repo. The referenced error file (below) appears to have the conditional blocks guarding the line numbers referenced in the error.

Below is the file that the error is referring to (I added line numbers for reference):

  1 {{ define "main" }}                                                                                                                                                                                                                                       
  2 {{ if (and .Parent .Parent.IsHome) }}                                                                                                                                                                                                                     
  3 {{ $.Scratch.Set "blog-pages" (where .Site.RegularPages "Section" .Section) }}                                                                                                                                                                            
  4 {{ else }}                                                                                                                                                                                                                                                
  5 {{$.Scratch.Set "blog-pages" .Pages }}                                                                                                                                                                                                                    
  6 {{ end }}                                                                                                                                                                                                                                                 
  7                                                                                                                                                                                                                                                           
  8 <div class="row">                                                                                                                                                                                                                                         
  9   <div class="col-12">                                                                                                                                                                                                                                    
 10     {{- if .Pages -}}                                                                                                                                                                                                                                     
 11     {{ $pag := .Paginate (( $.Scratch.Get "blog-pages").GroupByDate "2006" )}}                                                                                                                                                                            
 12       {{ range $pag.PageGroups }}                                                                                                                                                                                                                         
 13       <h2>{{ T "post_posts_in" }} {{ .Key }}</h2>                                                                                                                                                                                                         
 14       <ul class="list-unstyled mt-4">                                                                                                                                                                                                                     
 15         {{ range .Pages }}                                                                                                                                                                                                                                
 16         <li class="media mb-4">                                                                                                                                                                                                                           
 17           <div class="media-body">                                                                                                                                                                                                                        
 18             <h5 class="mt-0 mb-1"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h5>                                                                                                                                                                     
 19             <p class="mb-2 mb-md-3"><small class="text-muted">{{ .Date.Format ($.Param "time_format_blog") }} {{ T "ui_in"}} {{ .CurrentSection.LinkTitle }}</small></p>                                                                                  
 20             <header class="article-meta">                                                                                                                                                                                                                 
 21               {{ partial "taxonomy_terms_article_wrapper.html" . }}                                                                                                                                                                                       
 22               {{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}                                                                                                                                                          
 23                 {{ partial "reading-time.html" . }}                                                                                                                                                                                                       
 24               {{ end }}                                                                                                                                                                                                                                   
 25             </header>                                                                                                                                                                                                                                     
 26             {{ partial "featured-image.html" (dict "p" . "w" 250 "h" 125 "class" "float-left mr-3 pt-1 d-none d-md-block") }}                                                                                                                             
 27             <p class="pt-0 mt-0">{{ .Plain | safeHTML | truncate 250 }}</p>                                                                                                                                                                               
 28             <p class="pt-0"><a href="{{ .RelPermalink }}" aria-label="{{ T "ui_read_more"}} - {{ .LinkTitle }}">{{ T "ui_read_more"}}</a></p>                                                                                                             
 29           </div>                                                                                                                                                                                                                                          
 30         </li>                                                                                                                                                                                                                                             
 31         {{ end }}                                                                                                                                                                                                                                         
 32       </ul>                                                                                                                                                                                                                                               
 33       {{ end }}                                                                                                                                                                                                                                           
 34     {{ end }}                                                                                                                                                                                                                                             
 35   </div>                                                                                                                                                                                                                                                  
 36 </div>                                                                                                                                                                                                                                                    
 37 <div class="row pl-2 pt-2">                                                                                                                                                                                                                               
 38   <div class="col">                                                                                                                                                                                                                                       
 39     {{ if .Pages }}                                                                                                                                                                                                                                       
 40       {{ template "_internal/pagination.html" . }}                                                                                                                                                                                                        
 41     {{ end }}                                                                                                                                                                                                                                             
 42   </div>                                                                                                                                                                                                                                                  
 43 </div>                                                                                                                                                                                                                                                    
 44 {{ end }} 

I tried exploring and doing different things to see if I could isolate the problem. The only thing that seemed to work was to delete the file referenced in the error. After doing that, no more build errors, and it appears to have no effect on the output.
🤷

@chalin chalin added bug Something isn't working e0-minutes Effort < 60 min e1-hours p2-medium p3-low blog labels Jan 15, 2024
@chalin chalin added this to the 24Q1 milestone Jan 15, 2024
@chalin chalin modified the milestones: 24Q1, 24Q2 Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blog bug Something isn't working e0-minutes Effort < 60 min e1-hours p2-medium p3-low
Projects
None yet
Development

No branches or pull requests

2 participants