I noticed that when trying to create some specialized links to edit our opensource site https://github.com/nats-io/nats-site, that bundle type pages (_index.md, etc) report a name that is ‘incorrect’ in the specialized context.
In our site, the documentation pages have an ‘Edit in Github’ type button that takes the user to github and allows them to edit the file and submit a PR.
For such functionality {{.File.Path}} will report a name stripping the underscore which generates the wrong links to github. While correct for 99% of the sites, it would be useful to sport a ‘raw’ path, which actually telegraphs the actual name of the source.
Also while at it, there should be a .File.Name which is the actual name of the file, not including a path but sporting the name and extension without any manipulation.
Thinking out loud, in lieu of a path in the .GitInfo object, perhaps you could make a manifest file to parse in your templates.
This git command gets you a list of paths, or, one with hashes and paths:
git ls-tree -r --name-only HEAD
git ls-tree -r HEAD
Somehow I imagine you can script it to make a file that can be parsed by Hugo, matching, say, the hash you can get from .GitInfo to what’s in your generated (and/or formatted) file, to pull the path.
I think it sounds a bit on the complex side. I think the unexpected is that the filename is not the expected filename, even if it makes perfect sense. Likely the file is getting processed and renamed, and that ultimately it is the target name. Perhaps a ‘source’ name. Having the source of the file though regardless of what it is (think where git is not the source control system), would be useful. In any case .File.Name would be a wonderful thing.
Adding a {{ if eq .File.Path "index.md" }} and conditionally changing the name of the file solved it. - Note that is likely brittle, thus the inquiry about a .File.Name
If you check the link I pasted earlier, there’s a .LogicalName available. But I am surprised that the underscore is getting stripped… I don’t see that… Maybe because you are in a homepage branch bundle? Does the same happen for nested branch bundles (like in my example)?
… and .LogicalName has the underscore intact? Note that I wouldn’t use that because it’s just the file name without the full path. So it’s useless if you have sections at deeper levels.
I think we should understand why .Path is not doing the right thing for you, and fix that if needed.