hi
i edit the content of my site with obsidian or VSCode
the problem is that i have thousands of page bundles… and all these pages are “index.md” or “_index.md”
its not that wonderful setup to search and manage all the knowledge base if all files are named the same.
i was thinking: and if Hugo could be configured to read files named like its containing folder like it was an index?:
“/my-page/my-page.md” like it was “/my-page/index.md”
“/my-page/_my-page.md” like it was “/my-page/_index.md”
wouldn’t it be fantastic?
1 Like
Yeah that would be great. Except, it IS that great already.
my-page/my-page.md
---
url: /my-page/
---
Does the trick. You need to know, that doing it that way you will switch to my-page.md
being a single page, so the single layout will catch the content. If you want to change content you can use the layout
frontmatter and put a layout with that name into layouts/_default/layoutname.html
.
For deeper nested structures look at slug
, that will change only the last part of the URL.
2 Likes
thank you David
i use slug
a lot, already. i’ll give a try with the url rewriting
If you do this:
content/
└── post
└── post-1
├── b.jpg
└── post-1.md
and this:
+++
title = "Post 1"
date = 2021-04-04T21:21:34-07:00
draft = false
url = "/post/post-1/"
+++
This is content/post/post-1/post-1.md
Then as davidsneighbour describes, you will be able to visit the page at http://localhost:1313/post/post-1/
.
However, the template(s) used to render the page will not be able to access b.jpg
as a page resource using .ResourcesGet
or .Resources.GetMatch
. Page resources are only available to page bundles, and page bundles are those directories with either index.md
or _index.md
files at their root.
that’s the problem… i have tons of page bundles (posts, projects , tutorials) and i want to keep media without touching the templates…
if Hugo could think that “files named as containing directory” were index.md it would be much easier
2 Likes