{{ $mypage := "mypage.md#myanchor"}}
{{ with $.GetPage $mypage }}
{{ .RelPermalink }}
{{ end }}
I get: /mypage/
while I would have been expecting: /mypage/#myanchor
Is there a way to keep the anchor with GetPage, or another similar function. Otherwise, I can split the string if detecting #, evaluate the link, then add back the anchor, but if there is a standard option I am missing, that migth be better.
Didn’t find such option on GetPage, you probably need to handle it yourself.
Btw what are your use cases of this? There are some useful functions/shortcodes like relref and ref for getting the URL of pages, which will keep the anchor/fragment.
relref and ref appear to only work in shortcodes, not partials. If you have an option to have them work in partials, let me know.
Use case: I have a partial at the bottom of my articles with the references. In the markdown file, I have a section references at the top. Sometimes the point to external URLs, sometimes to other articles section on the site.