diff --git a/layouts/docs/single.html b/layouts/docs/single.html
index fc7ec57dd75a01255b1dab8472a0a0de92c33386..78f563ee15ef5d01a22204f664fcc6ec1c148726 100644
--- a/layouts/docs/single.html
+++ b/layouts/docs/single.html
@@ -1,9 +1,19 @@
{{ define "main" }}
- {{ $pt := (replace .Content ".md\"" ".html\"") }}
- {{ $pt1 := (replace $pt ".md#" ".html#") }}
- {{ $st := (replace $pt1 "‘" "'") }}
- {{ $ot := (replace $st "’" "'") }}
- {{- $ot | safeHTML -}}
+ {{ $content := .Content }}
+ {{ $links := findRE `(href|src)=(["'])([^"']+)(\.md)(["'])` $content }}
+ {{ range $links }}
+ {{ $link := . }}
+ {{ $attr := index (findRE `(href|src)` $link) 0 }}
+ {{ $quote := index (findRE `(["'])` $link) 0 }}
+ {{ $path := index (findRE `(href|src)=(["'])([^"']+)(\.md)(["'])` $link) 0 | replaceRE `(href|src)=(["'])` "" | replaceRE `(\.md)(["'])` "" }}
+ {{ if not (or (hasPrefix $path "http://") (hasPrefix $path "https://")) }}
+ {{ $newLink := printf "%s=%s%s.html%s" $attr $quote $path $quote }}
+ {{ $content = replace $content $link $newLink }}
+ {{ end }}
+ {{ end }}
+ {{ $pt := replace $content "‘" "'" }}
+ {{ $ot := replace $pt "’" "'" }}
+ {{- $ot | safeHTML -}}
{{ end }}
\ No newline at end of file