_index.md in subfolder (Hugo 0.20)

I have template for section \section\research.html

 {{ range .Data.Pages  }}
      {{ .Render "li" }}
 {{ end }}

In Hugo 0.17 it generated a list of pages from the section and subfolders. In Hugo 0.20, it does not generate anything if I add an _index.md to one of the subfolders. There are also no error messages.

If I leave the index.md in subfolder, it generates the list correctly, but the link to subfolders does like an research/subfolders/index/

Sounds related to this bug that got fixed in Hugo 0.20.1:

No, I do not use the block template.

But looks like the bug impacted the way base templates were derived for sections. Affecting block templates was just a part of it.

https://github.com/spf13/hugo/commit/077005e514b1ed50d84ceb90c7c72f184cb04521

See if updating to 0.20.1 fixes your issue.

I uploaded the file with the site to the cloud. https://cloud.mail.ru/public/47eU/7NtQWAo5C

There are few subfolders in the content\books that contain an index.md. If at least one index.md is renamed to _index.md, then Hugo first reports an error, and after restarting it ceases to generate the list for the section.

Have you read the docs on using _index.md files:

https://gohugo.io/content/using-index-md/

It doesn’t sound like you’re using them as intended in the newer way of doing things.

What exactly am I doing wrong?

If Hugo has stopped supporting subfolders, perhaps we need to delete these lines from the documentation?

In Hugo, the content should be arranged in the same way they are intended for the rendered website. Without any additional configuration, the following will just work. Hugo supports content nested at any level.

Hugo has not stopped supporting subfolders. The current doc looks correct to me. The _index.md in subfolder is covered by

@Mikhail I downloaded your code. This is the same setup that I have. You might be able to solve it by adding slug = '/' in the front matter of your index.md files.

I wanted to say a big THANK YOU to @bep and @rdwatters. I didn’t get to say thank you in this thread, where I tried to explain the same/similar issue, because it was closed while I was gone for a few hours. I think it was a bit misunderstood what I was trying to say: I absolutely LOVE the improvements you did in Hugo 0.20!

2 Likes

Thanks, it really works. I saw in another thread advice url=..., but it does not work.

See https://github.com/spf13/hugo/issues/3396

1 Like

My pleasure @marcojakob, although I"m not sure I helped, and I apologize for overlooking the index-index issue you mentioned before. I guess I was on autopilot when it comes to _index.md related questions on the forum.

P.S. In the interest of full disclosure, please know that I don’t write any of the actual code for this project. I’m just a content-forums-documentation guy. It’s @bep and all the other awesome devs that have contributed who deserve the credit for all the beautiful, fast, Golang that powers this awesome software. Cheers!

1 Like