TL;DR:
I want to see how I can create page bundles without naming my pages index.md
or _index.md
. For example, using README.md
to align with displaying the pages on Git hosting site web interface (Github, Gitlab, etc.)
Longer version:
I am moving my knowledge base to Hugo. It’s basically a Git repo where I write things in markdown and the index for each directory is README.md
(shows up when users navigate to that directory in the web interface). You can see the original one here: https://github.com/parsiya/Parsia-Clone
Updating the index takes a lot of time so I am migrating it to Hugo. I have modified my own theme for now. You can see a test version of the repo based on clone-2
branch: http://clone-test-bucket.s3-website-us-east-1.amazonaws.com/
The idea is that I can create a directory for each new entry, add the category, tags and summary in frontmatter and just publish it without needing to care about the index. The page bundle feature works perfectly for this because I can have all resources in the same path.
Problem is I need to name my files index.md
instead of readme.md
and this means they will not show up on Github or Gitlab when users navigate to the directory. While it’s not a must, it’s a nice to have so people can browse the repository too.
Looking at the source, it seems like index. / _index.
are hardcoded in:
// Returns the given file's name's bundle type and whether it is a content
// file or not.
func classifyBundledFile(name string) (bundleDirType, bool) {
if !isContentFile(name) {
return bundleNot, false
}
if strings.HasPrefix(name, "_index.") {
return bundleBranch, true
}
if strings.HasPrefix(name, "index.") {
return bundleLeaf, true
}
return bundleNot, true
}
Now I can do several things:
-
Rename every
README.md
toindex.md
before creating the Hugo website and then renaming them back after that before commit. This works for the most part but the Git link on top of every page will have to manually change the file name too. I am not sure how well that will work for CI because at the moment I do everything locally with some batch files. -
Build a custom version of Hugo and add
readme.md
.
What do you think? Is there a better way?