.Site.BaseURL in render-link markup

<a href="{{ .Destination | safeURL }}" 
{{- if or (strings.HasPrefix .Destination "amazon") (strings.HasPrefix .Destination "amzn") }}
    rel="nofollow sponsored noopener noreferrer" target="_blank"
{{- else if .Title }}
{{- else if findRE .Destination .Site.BaseURL }}
    rel="noopener" target="_blank"
{{- end }}
>{{ .Text | safeHTML }}</a>

So the .Site.BaseURL doesn’t work in this markup the error is

<.Site.BaseURL>: can't evaluate field Site in type goldmark.linkContext

How to fix this?

You have a context problem. Use either .Page.Site.BaseURL or site.BaseURL.

1 Like

Thanks It Worked <3

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