Show content of pages on homepage without individual pages

Hey everyone,
I’m creating a website that basically just consists of one long home page with »aspects« and »topics«. To better structure everything, I organise the content of the homepage through content files:

content
  - aspects
    - aspect1.md
    - aspect2.md
  - topics
    - topic1.md
    - topic2.md

The topics and aspects should not have their own page rendered. I only display the content by looping over site.Pages like this:

{{ range where site.Pages "Section" "topics" }}
  {{ partial "topic.html" . }}
{{ end }}

Everything is working fine except that I get the message: found no layout file for "HTML" for kind "page". I then used disableKinds = ["page"] but that results in the content also no longer displayed through site.Pages.

So my question is: How do I prevent Hugo from creating pages for every content file, while still being able to access it through site.Pages?

Thanks so much!

Sounds like what you need is headless bundles.

You can use new _build options. The Documentation also cover your case

“Listing pages without publishing them”

Thanks so much! I’m actually using both methods now. For aspects and topics, I decided to go for the headless bundles. Looks like excatly what I needed. Things are working as expected.

For anyone encoutering the same problem, here is what I did:

content
  - aspects
    - index.md # headless = true
    - aspect1.md
    - aspect2.md
  - topics
    - index.md # headless = true
    - topic1.md
    - topic2.md

And the looping looks like this:

{{ range (.Site.GetPage "/topics").Resources }}
  {{ partial "topic.html" . }}
{{ end }}

And since I have snippets like intro.md in the content folder, I’m using build there. I’m importing them like this:

{{ with .Site.GetPage "intro.md" }}
  {{ .Content }}
{{ end }}

Thanks so much again!

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