Indexes for sub directories

I’ve got a lot of content in folders like /<topic>/<sub category>/year/<topic-title> (eg /food/cake/2016/chocolate/and I’m wondering how I get index pages for subtopic and year generated?

I can get one generated for /<topic>/ by creating one for the type in /layouts/indexes/<topic>.html. I understand its likely got something to do with taxonomies but I’ve got no idea how to use them to be honest!

Any help would be greatly appreciated.

1 Like

No one has any idea?

In Windows 7 I use this cmd file

dir2index.cmd

for /F %%A in ('dir %1 /B') do (
     for /f "tokens=2 delims=:" %%I in ('type "%1\%%A" ^|findstr /B title:') do (echo - ^[%%~I^]^(%%~nA^/^) >>"%1\index4list.md")
)
pause

It should be placed at C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\SendTo\dir2index.cmd

And run through the right mouse button, select the folder and right-click send to>dir2index.cmd

It generate in the folder index.md like this:

- [ "hugo new theme"](hugo_new_theme/) 
- [ "hugo server"](hugo_server/) 
- [ "hugo undraft"](hugo_undraft/) 
- [ "hugo version"](hugo_version/) 

through find&replace need manually to remove " and replace "[ " to “[”

1 Like

Version 2.0

For list of files like ‘article1.md

dir2list.cmd

pushd "%1"
if exist index.md (
   rename  index.md index.%date:.=%.bak
)
for /F %%A in ('dir /a-d/b "*.m*"') do (
     for /f "tokens=2* delims=:" %%I in ('type "%%A" ^|findstr /B title:') do (echo - ^[%%~I%%J^]^(%%~nA^/^) >>index.md)
     echo. >>index.md
)
pause

For list of subfolders like article1/index.md

subdir2list.cmd

pushd "%1"
if exist index.md (
   rename  index.md index.%date:.=%.bak
)
for /F %%A in ('dir /ad/b') do (
     for /f "tokens=2* delims=:" %%I in ('type ".\%%A\index.md" ^|findstr /B title:') do (echo - ^[%%~I%%J^]^(%%~A^/^) >>index.md)
     echo. >>index.md
)
pause

subdir2list.cmd work only for the index.md, if presents index.mmark need to edit script.

If don’t need empity lines in the list remove the line ‘echo. >>index.md

Version 3.0

It generates a correct list of files which does not need further processing. Created with the participation of the cyberforum.ru.

For list of files like ‘article1.md

dir2list.cmd

pushd "%~1"
if exist index.md (
   rename  index.md index.%date:.=%.bak
)
for /f %%A in ('dir /a-d/b "*.m*"') do (
    for /f "tokens=1* delims=:" %%B in ('type "%%A"^| findstr /b title:') do (
        for /f "tokens=*" %%D in ("%%C") do (
            for /f "delims='" %%E in ("%%~D") do (
                echo - [%%E](%%~nA/^)>>index.md
                echo.>>index.md
            )
        )
    )
)
pause

For list of subfolders like ‘article1/index.md’

subdir2list.cmd

pushd "%~1"
if exist index.md (
   rename  index.md index.%date:.=%.bak
)
for /f %%A in ('dir /ad/b') do (
    for /f "tokens=1* delims=:" %%B in ('type ".\%%A\index.md" ^|findstr /B title:') do (
        for /f "tokens=*" %%D in ("%%C") do (
            for /f "delims='" %%E in ("%%~D") do (
                echo - [%%E](%%~nA/^)>>index.md
                echo.>>index.md
            )
        )
    )
)
pause

Interesting approach! I was hoping to find a hugo supported one (without the use of external tools) however I guess thats not possible.

I’m not on Windows so sadly that cmd file isn’t a solution but thanks for your help!!

I’m having the same issue. I’m not sure it’s possible, since top-level folders are treated in a special way as sections. The only sort-of work-around that I’m finding is to create a file with the same name as the folder. So, if you want an index page for 2016, create 2016.md and manually create the list.

I would like to see this feature become available. Seems like it should be possible.