Hay,
is there a way to let HUGO generate index.html files for every sub folder of Content (and their sub folders), as if an index.md was in there?
Preferably, this index.html should be generated from an separate template i define.
Thanks in advance
Silver
Not sure about what you want exactly, but you can try setting uglyURLs = true
in your config.toml
Thankβs a lot for your replay!
Sadly, that wonβt cut it.
I am gonna dump some Files into my Content folder, i donβt know how Many, how many folder s etc, and i donβt want to manually add index.md files to every one of them, so that i could acces via baseURL/Folder.
I need that step automated, that in every folder is an index.html with the content of one central template.md file.
If you start with this:
content
βββ posts/
βββ post-1/
β βββ a.jpg
β βββ b.jpg
βββ post-2/
β βββ a.jpg
β βββ b.jpg
βββ post-3/
βββ a.jpg
βββ b.jpg
And do this:
find content/posts/ -mindepth 1 -maxdepth 1 -type d -exec hugo new {}/index.md \;
You will get this:
content
βββ posts/
βββ post-1/
β βββ a.jpg
β βββ b.jpg
β βββ index.md
βββ post-2/
β βββ a.jpg
β βββ b.jpg
β βββ index.md
βββ post-3/
βββ a.jpg
βββ b.jpg
βββ index.md
The index.md
files will be created from the _default.md
archetype. To create the index.md
from a different archetype:
archetypes/
βββ _default.md
βββ posts.md <-- create from this one
find content/posts/ -mindepth 1 -maxdepth 1 -type d -exec hugo -k posts new {}/index.md \;
1 Like
Hay, Thanks a lot! That is really helpful!
Is it possible to use the templates out of the Themes Archetypes Folder?
Yes.
themes/mytheme/archetypes/
βββ default.md
βββ foo.md <-- use this one
find content/posts/ -mindepth 1 -maxdepth 1 -type d -exec hugo -k foo new {}/index.md \;
1 Like
Taking a moment to appreciate shell one-liners by @jmooring
system
Closed
May 9, 2021, 1:00am
8
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.