Potential bug? Content pages fail to generate

I’ve been trying to narrow down some unexpected behavior, and I’m not sure if it’s unexpected to me because I’ve failed to understand something fundamental to the hugo library, or if it’s actually unexpected and an indication of a bug.

Here’s what I’m observing:

  1. Generate a new hugo site
  2. Create a layouts/_default/single.html template
  3. Create a content/a.md markdown file

Generating the site with hugo creates the public/a/index.html page as expected.

If I then add a content/index.md file, then public/index.html gets generated with the content of index.md using the single page template, but a.md is no longer used to generate the a/index.html page.

If I build this up using three templates instead of just the one, then I can reproduce the issue with a.md not getting generated.

layouts/
├── _default
│   ├── list.html
│   └── single.html
└── index.html

If I create the content like this, then everything works as expected. I get a home page that uses the layouts/index.html file, and includes _index.md.

content/
├── _index.md
└── a.md

If I add a content/index.md file to this and regenerate, it’s all fine. The superfluous index.md file gets ignored. However, if I had mistakenly created an index.md instead of an _index.md, then a.md again doesn’t get generated. (The home page is also empty, of course, since there’s no _index.md to pull content from).

Is it a bug that a.md does not get generated in the presence of an index.md file?

No.

See Page bundles | Hugo

Ok, thanks for the pointer.

From the documentation I now realize where my mental model went wrong:

leaf means it has no children

Considering that index.md and a.md were in the same directory, I didn’t think of them as children, but as siblings. In retrospect they’re obviously children because hugo implicitly generates directories for them with a/index.html.

1 Like