and so on. Note, categories and subcategories have one html page, and alongside in subcategories are the items (“leaves” if you prefer) with data about these items.
I’ve found that, if I have an index.md page on the leaves, it is as expected.
But if I have an index.md on the category, no subcategory pages are created.
If on the other hand I create an _index.md file under category, the subcategory is created but instead of creating an /category1/index.html , a /category1.html file is created.
I can understand the logic behind it and with data-duplication (i.e. data in both index.md and _index.md) I could solve this issue, but as a programmer I hate duplication.
Thus I decided to ask for help in the gurus here, to tell me if there’s a way to handle this or if I am doing something fundamentally wrong.
index.md and _index.md are Hugo’s way of determining whether your Page Bundle is a leaf or a branch bundle.
index.md = leaf bundle = no child pages = no subcategories generated in your case. Any page-type content (subcategory pages in your case) are treated as Page Resources. You can access their .Content, but these will not have a .Permalink.
Since I don’t want to change my old site URLs (and don’t want to depend on apache’s tricks to do the same thing), I’d prefer, if possible, the generator to do this for me.
So, as I said with the original question, I need the section url to be an “index.html” file under the folder named as the section, and alongside the “leaf” pages to be named as “itemX.html”, instead of “itemX/index.html”.
So right not I am duplicating _index.md and index.md so, that a “/category/index.html” and “/category.html”, alongside “category/itemX.html” will exist (while practically I’ll ignore “category.html”).
I am trying to do something similar with permalinks, to rename either of it, but still fail to do so.
At least, if this could not be done, to have a second look and see what I can do instead!