Hugo generate index.html in all folders, even empty folders


I’m using v26, but I faced this issue in v25.1 too.

In content folder I have:


I expected hugo generate this:


But hugo generate:


Is there any related config or it’s a bug?


It is as designed.

The extra index.html files are empty. is there any way to tell hugo don’t generate them?

The big problem is, the link of this unexpected index.html files are in generated sitemap.xml too.

You can create a single page and override it’s url:


title: C
url: /a/b/c

Now, you still get /c/index.html. I don’t know how to prevent hugo from creating that page. But you’re a step closer.

I suggest you adjust your template and make sure they’re not empty. It is called nested sections.



Will give you sections A, B, and C.

If you don’t want a section in C, then don’t put a “” in it; try “”.

Thanks for the answer.
Using inside C give me A/index.html but I need to have A/B/C/index.html, I used nested folders, because I want to have more keywords in my urls. seo thing I mean.

How I can get that URL but not that empty/extra index.htmls.

I solved this by usingURL in front matter section.

No instead of using nested folders, I put file in root of content folder, and set url option to what I want.

Thanks for your time and answers.

It’s bad practice to have a directory without an index file in it, and even worse to add directories that aren’t needed. Search engines are likely to lower your ranking for that.

If you really want keywords in your URL, then have one directory named A-B-C not three nested ones to give you A/B/C (unless you have content for A or B too).

1 Like