Create a absURL to a bookmark

I need to create a URL to a bookmark but something is not going as hoped:

<a href="{{ .button.href | absURL }}" class="btn btn-outline-dark mt-4">{{ .button.text }}</a>

This is the JSON:
if I put the # character before contact, the resulting URL is only the baseURL, while if I remove the # character, the URL is correct, but I need to create a URL to a bookmark, so I need the # character

"button" : {
              "text" : "Scegli",
              "href" : "#contact"

May be you can play around this :

no # in your json/href

"button" : {
              "text" : "Scegli",
              "href" : "contact"
{{ $anchor := printf "%s%s" "#" (anchorize .button.href) }}
<a href="{{ $anchor | relURL }}" class="btn btn-outline-dark mt-4">{{ .button.text }}</a>

And for anchor links, I guess using absURL doesn’t make real sense (see absURL function seems to eat HTML anchor-links)

1 Like

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