I’ve been reading through the content types and archetypes documentation and wonder if it’s possible to have Hugo create a new _index.md file for new subsections? An example may help:
In my content directory, I have a blog section. Blogs are organised in subsections of year and again of month. This gives a tree that looks a bit like this:
Given that each month, and each new year, a new directory is created and should have an _index.md with pre-populated front matter, is it possible for Hugo to generate this?
Using the above tree as an example, suppose now we are in 2018 I create a new blog hugo new blog/2018/1/some-post.md, can Hugo be configured to create _index.md in both the 2018 and 1 directories? And then in February, when I do hugo new blog/2018/2/some_other-post.md, create _index.md in 2? And so on?
Having implemented the latter, I have 2 questions:
Is it possible to generate a list of items that fall under localhost:1313/2017/10, or /2017, or /2018, etc? Or is the answer still no?
Previously, when I had the link as /blog/2017/12, I had a blog menu item that was highlighted whenever anything under /blog was the current page. This no longer works. How should I adapt the following snippet to provide this same functionality?
So if I script that, I’m trying to understand the steps involved. As I see it, it would be:
Loop through all posts and read the date of each.
For each distinct year, create a folder for that year.
For each folder created, create an _index.md file.
Run hugo, which will merge the created folders with the generated folder structure, which will then additionally include list pages for each of the years.
You will have to come up the script yourself (this is not some corporate support), but as I said: You need to create the file at the lowest level (which I guess is the month); the content of that file does not matter too much for this (you would probably want a date) as long as it is a valid content file with front matter.