Use default templates on homepage

I want to use the homepage to display a list of all pages, grouped by sections. I would like to integrate as deep as possible with the existing templates in /layouts.

How do I refer to the default templates on the homepage? Ideally I would just range through the sections and then display the list template for each section defined in /layouts/sectionname/list.html. But I do not find a way to reference that template from the homepage.

If I use e.g. {{ template “_default/single.html” }} or {{ template “post/single.html” }} the template is not found and hugo throws an error.

Use .Render.

Here’s a little snippet to put in your layouts/index.html that will list summaries of last 10 modified pages.

The key is {{ .Render "summary"}}. The summary is my summary view template. See the docs for info on Views.

Similarly you can use the li or single view if you like.

<!-- Have the paginator list posts, sorted by last modified date, most recent first -->
{{ $paginator := .Paginate (.Data.Pages.ByLastmod.Reverse) 10 }}

<div class="posts">
    {{ range $paginator.Pages }}
        {{ .Render "summary"}}
    {{ end }}

For more information on .Render and layouts, see the docs for content view templates.