Skip to content

hugo server: Pagination error with slice of pages created using Scratch/Store #11853

@CamilleScholtz

Description

@CamilleScholtz

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.121.1-00b46fed8e47f7bb0a85d7cfc2d9f1356379b740+extended darwin/arm64 BuildDate=2023-12-08T08:47:45Z VendorInfo=brew

Does this issue reproduce with the latest release?

The part of the template that seems to break is the following:

	{{ $.Scratch.Add "sortedPages" slice }}
	{{ range .RegularPages.ByDate.Reverse }}
		{{ if not .Params.out_of_stock }}
			{{ $.Scratch.Add "sortedPages" (slice .) }}
		{{ end }}
	{{ end }}
	{{ range .RegularPages.ByDate.Reverse }}
		{{ if .Params.out_of_stock }}
			{{ $.Scratch.Add "sortedPages" (slice .) }}
		{{ end }}
	{{ end }}
	{{ $paginator := .Paginate ($.Scratch.Get "sortedPages") }}

The generated error is:

render of "section" failed: �[1;36m"/Users/camille/Developer/Home/reactionair.nl/layouts/shop/list.html:73:18"�[0m: execute of template failed at <.Paginate>: error calling Paginate: cannot convert type []interface {} to Pages Failed to render "/winkel/": render: failed to render pages: cannot convert type []interface {} to Pages 

	{{ $paginator := .Paginate ($.Scratch.Get "sortedPages") }}

This only happens when running hugo serve, not hugo or Hugo serve --disableFastRender.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions