diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html
index 00f1874a..6e73759d 100644
--- a/layouts/_default/_markup/render-link.html
+++ b/layouts/_default/_markup/render-link.html
@@ -1,9 +1,9 @@
{{- $link := .Destination -}}
{{- $isRemote := strings.HasPrefix $link "http" -}}
{{- if not $isRemote }}
- {{ $url := urls.Parse .Destination }}
+ {{- $url := urls.Parse .Destination -}}
{{- if $url.Path }}
- {{ $fragment := "" }}
+ {{- $fragment := "" }}
{{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}}
{{- with .Page.GetPage $url.Path }}
{{ $link = printf "%s%s" .RelPermalink $fragment }}
@@ -14,5 +14,4 @@
{{ end -}}
{{ end -}}
{{ end -}}
-
-{{- .Text | safeHTML -}}
\ No newline at end of file
+{{- .Text | safeHTML -}}
\ No newline at end of file