HUGO

Safe to ignore "have both index.* and _index.* files, pick one."?

I disabled the section kind and am creating my own sections structure.

In order to show the custom-section page, I’m using /my-section/index.md.
In order to show a post in a subdirectory path, I’m using /my-section/_index.md.

If I remove either of those things, the respective functionality stops working.

However, I’m now getting:

Content directory “/content/my-section” have both index.* and _index.* files, pick one.

Is this warning safe to ignore in my case? Or is there a different way to resolve this?

Well, if you care about both of them, I would say no. Hugo will pick one of them (I don’t remember which one). If having both of them makes “stuff work”, I suspect that is not really true.

‘_index.md’ is the file that makes your directory a section and represents the list page.

‘index.md’ is the file that makes your directory a page bundle and represents the main page of the page bundle.

You should use only ‘_index.md’.