Disable generating empty index.html pages created for sections

I know this is an old post, but I recently stumbled (again) over the same issue.
There is a simple (but rather undocumented) way to do this. You need to set the _build flag for the branch bundle (see Page Bundles | Hugo) within _index.md and adjust for the children using cascade.

This is a working _index.md (confirmed with 0.112.6) that does the trick for me:

---
_build:
  render: never
  list: never
  publishResources: false
cascade:
  _build:
    list: false
    render: true
title: Survey
url: /survey/
---

This is the tree of the source (multilingual site):

tree content/en/survey/
content/en/survey/
├── _index.md
├── it-security-starts-with-top-management.md
└── lets-start-talking.md

and this is the rendered output:

tree public/en/survey/
public/en/survey/
├── information-security-begins-in-the-management
│   └── index.html
└── lets-start-talking
    └── index.html

As you can see, this technique prevents the (empty) index.html from being built for the root section, but the children are still there.

The use case here are landing pages that can be reached by finishing a survey in an external limesurvey instance. They need to have a common section, but should not have an index.

1 Like