hugo icon indicating copy to clipboard operation
hugo copied to clipboard

mounts: Add name mapping config option

Open bep opened this issue 3 years ago • 5 comments

I'm doing some foundational improvements to Hugo, and I stumbled over some limitations to single file mounts (as in: Not a directory). These mounts were intended to be used for directories, that the file mounts worked was a little accidental. One use case would be the below:

[module]
  [[module.mounts]]
    source = "README.md"
    target = "content/_index.md"

There are some limitations to the above, and it also makes the mount code unnecessarily complex. So, with the work I'm doing right now I'm rewriting the above to be a directory mount with a source filter (README.md) and a name map (README.md<=> _index.md).

I have not exposed this feature in the config yet, but I suspect it would be really useful, as described in #4691

I'm not sure how it would look, maybe:

[module]
  [[module.mounts]]
    source = "." # Project root
    target = "content"
    includeFiles = "**/*.md"
     [[module.mounts.renames]]
     "README.md".to "_index.md"

bep avatar Jul 28 '22 08:07 bep

I don't know if this is the right place to show support for this, but I have an additional use case that I think this would solve and right now is a blocker for me to switch to Hugo.

I use Ulysses external folder support for my writing, and they use textbundle format for their "posts" -- http://textbundle.org

The spec uses text.md as the markdown container within the textbundle and assets/* for relative images.

CleanShot 2022-11-19 at 10 09 56@2x

Since the only way hugo resolves relative images is through a leaf bundle (which currently requires index.md or _index.md) this means that images are broken in those posts when rendered in hugo.

My blog has a mix of index.md leaf bundles and Ulysses textbundles, so it would ultimately need to support both (not just a simple config option telling hugo which file to look for in the leaf bundle)

markphilpot avatar Nov 19 '22 18:11 markphilpot

Any updates on this?

Would be really nice to be able to use README.me as it would render the folder automatically on GitHub when surfing the repo.

quicoto avatar Feb 08 '23 15:02 quicoto

This is definitely not the way hugo will probably do this for real, but if anyone is looking for how to get hugo working with TextBundles, I have a branch here that you can use -- https://github.com/gohugoio/hugo/compare/master...markphilpot:hugo:mark/textbundle-support

I just built a custom hugo binary for building my blog, which has both vanilla index.md leaf nodes, as well as text.md TextBundle assets.

markphilpot avatar Sep 11 '23 02:09 markphilpot

Is this there any buy-in for including this? I came across this exact need today when setting up a new project with the README -> _index rename

vindard avatar Jul 23 '25 14:07 vindard

Anything we can do to help advance this feature or at least get it onto an upcoming release roster? :) Explicit mount lists are becoming a head-ache to deal with when it comes to merge-conflict resolution. Here's an example of our current explicit mount list: https://github.com/open-telemetry/opentelemetry.io/blob/75bc6d91e53cc110843381f80b2506c83821d32e/hugo.yaml#L281-L363. I'd love to be able to replace that list with a kind of wildcard. Thanks!

chalin avatar Oct 30 '25 19:10 chalin