diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html
index c720c458..7ae8a3e9 100644
--- a/layouts/_default/_markup/render-link.html
+++ b/layouts/_default/_markup/render-link.html
@@ -1,10 +1,11 @@
{{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}}
-{{$trimmed = replace $trimmed "%20" "-" }}
-{{$external := strings.HasPrefix $trimmed "http" }}
+{{$dashedurl := replace $trimmed "%20" "-" }}
+{{$external := strings.HasPrefix $dashedurl "http" }}
{{- if $external -}}
-{{ .Text | safeHTML }}
+{{ .Text | safeHTML }}
{{- else -}}
-{{$fixedUrl := (cond (hasPrefix $trimmed "/") $trimmed (print "/" $trimmed)) | urlize}}
-{{$rooted := strings.TrimRight "/" (.Page.GetPage $fixedUrl).RelPermalink }}
+{{$spacedurl := replace $trimmed "%20" " " }}
+{{$fixedUrl := (cond (hasPrefix $spacedurl "/") $spacedurl (print "/" $spacedurl)) | urlize}}
+{{$rooted := default $spacedurl (strings.TrimRight "/" (.Page.GetPage $spacedurl).RelPermalink) }}
{{ .Text | safeHTML }}
{{- end -}}
\ No newline at end of file