Where to put a layout file for a page bundle?

What I’ve tried

$ hugo new contributors/index.md

In content/contributors/index.md:

---
title: Community Contributors
date: 2022-04-03T11:00:02-04:00
draft: false
contributors:
  joe: ...
  jane: ...
---
some content

in layout/contributors/index.html:

{{ define "main" }}
  {{ $.Content }}

  {{ range $name, $x := $.Params.contributors }}
    {{ $name }}
  {{ end }}
{{ end }}

edit: I’ve also tried placing this template in baseof.html, single.html, and list.html

What happens

The /contributors page is rendered without the list of contributors. It looks like the default layout is being applied.

Expected

The layout at layout/contributors/index.html to be used, rendering the list of contributors from the frontmatter.

1 Like

Hiya @dscottboggs. :wave:

So, when you create content/contributors/index.md, you are actually creating a leaf bundle, but it isn’t in a contributors section, it’s in the root section, thereby using the layouts/_default/single.html template.

There are different approaches to get that content into place, but if you just want that single page you can do the following:

  1. Add layout: contributors to your front matter, and
  2. Move layouts/contributors/index.html to layouts/_default/contributors.html
---
title: Community Contributors
date: 2022-04-03T11:00:02-04:00
draft: false
contributors:
  joe: ...
  jane: ...
layout: contributors
---
some content

Let me know if that makes sense. :slight_smile:

2 Likes

If you just want single page

  1. try rename your page template then move to: layout/page/contributors.html
  2. create new page: $ hugo new content/contributors.md
  3. Add corresponding layout in your front matter:
---
title: Community Contributors
date: 2022-04-03T11:00:02-04:00
draft: false
layout: contributors
contributors:
  joe: ...
  jane: ...
---
some content

Now visit /contributors