diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html
index 7d21679..15411a3 100644
--- a/layouts/_default/_markup/render-heading.html
+++ b/layouts/_default/_markup/render-heading.html
@@ -1,6 +1,6 @@
-{{ $showAnchor := (and (default true .Page.Params.GeekdocAnchor) (default true .Page.Site.Params.GeekdocAnchor)) }}
+{{- $showAnchor := (and (default true .Page.Params.GeekdocAnchor) (default true .Page.Site.Params.GeekdocAnchor)) -}}
-{{ if $showAnchor }}
+{{- if $showAnchor -}}
{{ .Text | safeHTML }}
@@ -9,10 +9,10 @@
-{{ else }}
+{{- else -}}
{{ .Text | safeHTML }}
-{{ end }}
+{{- end -}}
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html
index 281697d..2105412 100644
--- a/layouts/_default/_markup/render-image.html
+++ b/layouts/_default/_markup/render-image.html
@@ -1 +1,2 @@
+{{- /* Drop trailing newlines */ -}}
diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html
index 22b1bd1..2963c43 100644
--- a/layouts/_default/_markup/render-link.html
+++ b/layouts/_default/_markup/render-link.html
@@ -1,2 +1,3 @@
{{- $raw := or (hasPrefix .Text "{{ .Text | safeHTML }}
+{{- /* Drop trailing newlines */ -}}