.Site.Params "externallinktarget" }}
    {{- $target = $page.Site.Params.externalLinkTarget }}
  {{- end }}
  {{- $attributes = $attributes | merge (dict "target" $target) }}
{{- else }}
  {{- $linkPage := "" }}
  {{- $path := strings.TrimPrefix "./" $u.Path }}
  {{- if $path }}
    {{- with or
      ($page.Page.GetPage $path)
      ($page.Page.GetPage (strings.TrimRight "/" $path))
      ($page.Page.Resources.Get $path)
      (resources.Get $path)
    }}
      {{- $linkPage = . }}
    {{- else }}
      {{-