Error creating page for list of posts

I’m trying to create a new page ‘Blog’ that lists all the posts, instead of the homepage. To do this, first I created a new blog.md in content with this frontmatter:

---
title: "Blog"
layout: blog
---

And then I created a new .HTML in layouts/_default called blog.html, where I’ve entered this:

{{ define "main" }}
{{ partial "articles/articles.html" . }}
{{ end }}

This is what was used on the homepage to display posts, so I figured it should work if I created a page for it on its own too.

But this gives me the following error:

Rebuild failed:

Failed to render pages: render of "page" failed: execute of template failed: template: _default/blog.html:3:3: executing "main" at <partial "articles/articles.html" .>: 
error calling partial: execute of template failed: template: partials/articles/articles.html:3:5: executing "partials/articles/articles.html" at <partial "articles/list.html" .>: 
error calling partial: "D:\Srishti\Year 2 Semester 1\Blogdown\Website\themes\hugo-theme-novela\layouts\partials\articles\list.html:7:47": execute of template failed: template: partials/articles/list.html:7:47: executing "partials/articles/list.html" at
 <$paginator.Pages>: error calling Pages: runtime error: invalid memory address or nil pointer dereference
Hugo Static Site Generator v0.79.0/extended windows/amd64 BuildDate: unknown

How can I do this?

We don’t know what’s going on inside your partial. Please read Requesting Help and add a link to your repo.

Edit to add:

Your error is complaining about $paginator. My guess would be that you have paginator code in your partial. blog.md is a single page, and paginators only work in a list page context.

This is a link to my partials/repo, does this work? https://github.com/thedivtagguy/website/tree/master/themes/hugo-theme-novela/layouts/partials

Edit: How would I make this a list page?

You would use blog/_index.md instead.

1 Like

Thank you, that works beautifully!

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