I have created a basic page content type which will serve multiple templates. The idea is to be able to specify a template for a specific content type otherwise render a standard template (a common requirement).
I am pulling in the content dynamically using the contentful to hugo plugin https://github.com/ArnoNuyts/contentful2hugo. The data (markdown files) is pulled in directly to the hugo/content folder without sub folders. Therefore I am relying on the type value to arrange content.
I am able to iterate over content using the range function however if I try to apply pagination I receive an error:
ERROR: 2016/04/20 template: partials/blog.html:77:19: executing “partials/blog.html” at <.Paginate>: error calling Paginate: Paginators not supported for content pages. in partials/blog.html
Code:
basic_page/single.html:
{{ if isset .Params “template” }}
{{ if in .Params.template.api_object.fields.title “template_blog” }}
{{ partial “blog” . }}
{{ end }}
{{ else }}
{{ end }}
blog.html partial
{{ $paginator := .Paginate (where .Site.Pages “Type” “post”) }}
{{ template “_internal/pagination.html” . }}
{{ range $paginator.Pages }}
{{ .Title }}
{{ end }}
{{ range $index, $element := (where .Site.Pages “Type” “post”) }}
{{ if eq $index 0 }}
{{ .Render “summary-first” }}
{{ else }}
{{ .Render “summary” }}
{{ end }}
{{ end }}
The error is pretty clear however can anyone recommend a workaround? The pagination works fine from the homepage however my guess is that by calling it from the single template there is different context and it is failing.
Any recommendations on how I can achieve this? I guess the main issue is that I cannot use sub-folders. The reason I am using a basic page type is so authors can alter the ‘landing pages’ so they can change things like blog header/header image which is rendered on all blog pages.