I don’t think so. I was thinking about creating a small “proof of concept” doing this, but this Christmas has been lazy … It should not be too hard, tough, the clues being:
use Markdown links either “root relative”, e.g. “/docs/my-page.md” or page-relative, e.g. “my-page.md”, “…/blog/my-article.md” etc.
Then use {{ (.Page.GetPage .Destination).RelPermalink }} in the hook template (with some added checks for the “not found case”)
Note that the project itself doesn’t run with the current Hugo version. I thought I should be clever and use the README.md as the home page content file, but there were some missing pieces re. mounting of content files (i.e. not directories). I will get to that in a bit …
Your repository is giving me error: Error: Error building site: process: readAndProcessContent: walk: Readdir: fdopendir: not a directory but this is something your are already on the top of it.
Even if I use your render-link.html template and even if I add markup section into config.yaml (not sure if that is required), I am unable to generate the working link - keep generating the original url.
Yes, it made made me go back and test it. I made my test site a little too complicated (the mounts from blog => posts), which made me think that GitHub did not support “…” style of links. But all in all a good thing that I got to fix these issues.
Can the content of that github link be added into the hugo docs regarding render-link.html or integrated into a future release?
It nicely fixes the problem hugo seems to have always had of links to anchors in other markdown docs, i.e. [link](some-page.md#an-anchor-link) - never used to render to html correctly.
{{ $link := .Destination }}
{{ $isRemote := strings.HasPrefix $link "http" }}
{{- if not $isRemote -}}
{{ $url := urls.Parse .Destination }}
{{- if $url.Path -}}
{{ $fragment := "" }}
{{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}}
{{- with .Page.GetPage $url.Path }}{{ $link = printf "%s%s" .RelPermalink $fragment }}{{ end }}{{ end -}}
{{- end -}}
<a href="{{ $link | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank"{{ end }}>{{ .Text | safeHTML }}</a>