Hugo server doesn't serve until I save file? (Debugging difficulties)

I’m having difficulties setting up my theme, because hugo server jumps between serving and not-serving files.

Right now when I start it, it serves a blank, or rather a <pre></pre> response. When I save a file, e.g. in the content tree (without changing it) and refresh the page, Hugo registers the event and serves again.

Is there some way I can get more information out of Hugo? The --verbose flag is not more informative. I also tried --gc in case some cruft was left in the pipeline.

Hi there,

Do you have your code somewhere we can have a look at? There may be something wrong with your layouts or how your site is configured.

Here’s my basic layout, maybe some obvious mistake jumps out at you?

├── config.toml
├── content
│   ├── index.md
│   ├── events
│   │   ├── apple.md     ← "saving" these makes hugo serve /events/ again
│   │   ├── orange.md
│   │   └── banana.md
│   ├── gallery
│   │   └── index.md
│   └── projects
│       └── index.md
├── static
│   └── …
├── themes
│   └── foobar
│       ├── assets
│       │   └── scss
│       │       └── _index.scss
│       ├── layouts
│       │   ├── 404.html
│       │   ├── _default
│       │   │   ├── baseof.html    ← base template
│       │   │   └── single.html
│       │   ├── events
│       │   │   └── list.html      ← also extends from base template (problem?)
│       │   └── partials
│       │       └── …
│       └── static
│           └── …
└── …

I can try to create a sample later if necessary, I hope I can reproduce the issue. Thanks.

├── content
│   ├── index.md    

This should be _index.md

...
├── themes
│   └── foobar
│       ├── layouts
│       │   ├── 404.html
│       │   ├── _default
│       │   │   ├── baseof.html    ← base template
│       │   │   └── single.html
│       │   ├── events
│       │   │   └── list.html      ← also extends from base template (problem?)

You don’t have a default list.html template.

This should be _index.md

But that’s my homepage (not a list page), shouldn’t it stay as is?

You don’t have a default list.html template.

Yeah, I won’t have any list pages aside from /events/, so I’m keeping the layout as sparse as possible to avoid confusion/duplication. Hugo doesn’t seem to look for a default list template in this arrangement.


What I did notice now is that Hugo doesn’t see my files until I save them! So it returns blanks because it thinks /content/events/ is empty!

I rebooted in-between so this doesn’t appear to be some synchronization issue with my text editor. The project is located in a regular filesystem along with my OS, nothing unusual. Weird!

Edit: Someone stumbled upon the same problem it seems.

I’ve filed an issue on GitHub. Maybe I’m just doing something wrong, but it’s not obvious from the documentation, so either way something insightful should come of this.

Ok, here’s what I found out:

The odd behavior was caused by having /content/index.md instead of /content/_index.md as pointyfar pointed out. For me the former worked (misleading!) and the latter didn’t because I had

disableKinds = ["home", …]

in my config.yaml, thinking it would just disable the need for a dedicated homepage template, not the rendering of that page per se.

So the solution is:

  • Don’t disable homepage kind
  • Rename homepage to /content/_index.md
  • (Add homepage template)

Now Hugo sees items under the /content/events/ section just fine without the shenanigans described in my first post. “Debugging difficulties” indeed :sweat_smile: