Home page filename has to be _index?

Hi all, new to Hugo and just getting started. Think I’ve figured most of it out that I need for my first site but one thing has come up…

I have a simple structure, I’ve just created 3 pages to start with to get it working:
_index.html
about.html
contact.html

Please correct me if I’m wrong but as I understand it, the _ prefix tells Hugo that this is a list page and it uses the list layout. If the _ prefix is not there then it uses the single layout. I realise that for the home page the home layout is used.

My home page _index is not a list. But, if I rename it to index (without the _) then Hugo doesn’t seem to notice the about and contact pages and add to the menu. If the home page is _index, with the _ prefix, then the menu is generated and the About and Contact pages appear.

I have tried defining the menu automatically in front matter, and also in the hugo.toml file but the behaviour is the same both ways.

Is something going on here that I’m missing?

The home page must be named _index.md.

At some point we’ll start throwing an ignorable error if you name it index.md. See:
https://github.com/gohugoio/hugo/issues/13538

I understand your home page isn’t a list page, so you can either:

  1. Edit the home page layout (or override if using a theme) so that it doesn’t list any pages (i.e., show content only).
  2. Specify a layout in front matter:
title: home
layout: foo # no extension

https://gohugo.io/content-management/front-matter/#layout

Perfect, thanks for the quick reply.

I have already edited the home layout as you suggested, just wanted to check I wasn’t missing something.

Thanks for the explanation.

1 Like

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