{{- $parsedDest := urls.Parse (.Destination | absURL) -}}
{{- if (strings.HasPrefix .Destination "#") -}}
{{ .Text | safeHTML }}
{{- else if not (strings.HasPrefix .Destination $parsedDest.Scheme) -}}
{{- $baseURL := trim .Page.Site.BaseURL "/" -}}
{{- $fragment := "" -}}
{{- with $parsedDest.Fragment -}}{{- $fragment = printf "#%s" . -}}{{- end -}}
{{- $href := printf "%s%s%s" $baseURL $parsedDest.Path $fragment | absURL -}}
{{ .Text | safeHTML }}
{{- else -}}
{{ .Text | safeHTML }}
{{- end -}}