{{ $url := .Destination }} {{- if (strings.HasPrefix $url "http") -}} {{/* external link, add icon */}} {{ .Text | safeHTML }}open_in_new {{- else if (strings.HasPrefix $url "/") -}} {{/* absolute link, use url as-is */}} {{ .Text | safeHTML }} {{- else -}} {{/* check if the file links to index.md */}} {{- if (strings.FindRE `([^_]|^)index.md` $url 1) -}} {{ .Text | safeHTML }} {{- else -}} {{/* relative link, use ref */}} {{ .Text | safeHTML }} {{- end -}} {{- end -}}