HUGO

New to Hugo | is what I'm trying to do possible?

Hello!

I’m learning Hugo to decide whether I want to use it in an upcoming project. I really appreciate how Hugo (and SSGs in general) separate the page format from the page content. However, as far as I understand from the tutorials, Hugo generates one page per content file. I don’t always want this; some I want content files that can show up in List pages, but don’t have Single pages associated with them. Is this possible?

As a concrete example, say I have a biography page with a dozen short (2 paragraph) bios. Each bio is conceptually distinct, and I want each bio to have its own distinct Front Matter. Then, I will have a List page that displays all the bios. However, I specifically do NOT want a separate Single page generated for each bio. Bios can only be displayed as a list, not individually. Is this type of content-list-without-individual-content-pages approach possible in Hugo?

Thanks!

Hi, there’s pretty much first-class support for this!

You can use leaf bundles. Have a content/biographies/index.md with general content for the “list” page, and a markdown file for each person like content/biographies/jane-doe.md. No pages are generated for markdown files except index.md
In the corresponding biography single page template you can do this:

  <h1>{{ .Title }}</h1>
  <p>{{ .Content }}</p>
  {{ range .Resources.ByType "page" }}
    <h1>{{ .Title }}</h1>
    <p>{{ .Content }}</p>
  {{ end }}

You can of course put the biography markdown files to a deeper subfolder and access them with .Resources.Match instead.
If you don’t want to render the biography/index.md either, you can add headless: true to its front-matter and access the biography entries as specified here.

1 Like

So there are two ways to do this:

  1. [Headless] Leaf Bundles as @madispe was mentioning
  2. Data Files
    Which will allow for access across the site since they live within the root directory of the site (kind of like /assets). This way is also nice since it maps conceptually to the other difference between hard-edited content and reusable data.