Local links with "./" don't work (anymore)

Hi, I used to employ the ./some-anchor notation, with the leading dot, to indicate a local link. It used to be translated automatically into the good permalink, without hardcoding “prefix . = .Page.Permalink” or something like that. Now .Destination = “./bonobo” for instance gives:

{{- $url := urls.Parse .Destination }}
		{{- $page := site.GetPage $url.Path }}
		{{- $fragment := $url.Fragment }}
		{{- if $page }}
			{{- $destination = $page.RelPermalink }}
			{{- with $fragment }}
				{{- $destination = print $destination "#" $fragment }}
			{{- end }}
		{{- else -}}
			{{with resources.Get .Destination}}{{ $destination = .RelPermalink}}{{end}}
		{{- end }}

gives the root page plus the fragment. I really don’t remember having touched the code, but I don’t know. Thanks for looking at it, if it seems like a normal behavior.

I’ve read this post several times and I still don’t understand it.

One thing I noticed is that you are calling .Site.GetPage instead of .Page.GetPage. Relative links (e.g., ./something) only make sense with .Page.GetPage. In a render hook you should always use .Page.GetPage.

Also, when posting code, configuration, or data on this forum, please wrap the text within triple backticks or use the </> button in the menu.

my code

Don’t use blockquotes.

You understood enough to give the answer :rofl:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.