Worked in v0.64.1 and stopped working in v0.65.0. Still not working with v0.68.3
Minimal reproducible example: Github
Uses example render-link.html from bep’s demo
Edit: I use this to utilize hugo’s render hooks
With the example, I expect the [test](hello#test) in content/_index.md should resolve to /dir1/dir2/dir3/hello/#test (which it does in 64.1).
However, in 65+ it resolves to /hello#test (and shows 404)
I don’t believe it’s using the markdown processing since it should be using hugo’s render hooks (should of mentioned this more explicitly).
Testing it by modifying render-link.html showed that to be true.
This gives you full control over how links and images in Markdown are rendered without using any shortcodes.
my config has this
markup:
goldmark:
renderer:
unsafe: false
So I think it uses goldmark for both versions when I’m testing it.
What I’m looking to do is use the render hook to basically simulate {{< ref “document.md” >}}.
Bep’s example worked until v0.65.0 and then showed my first posts behavior.
Minimal reproducible example: Github
With the example, I expect the [test](hello#test) in content/_index.md should resolve to /dir1/dir2/dir3/hello/#test (which it does in 64.1).
However, in 65+ it resolves to /hello#test (and shows 404)
You must use .Page.GetPage in the hook (I’m not using !) + a hint for me
My example in the sample repository does:
{{/* https://github.com/bep/portable-hugo-links/blob/master/layouts/_default/_markup/render-link.html */}}
{{- $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 -}}
[test](/dir1/dir2/dir3/hello.md/#test) should work
Yes it does, which is good.
In links and cross references, there is this example:
{{< ref "document.md#anchor" >}} which is the same style that I was using that was working until the version change.