diff --git a/layouts/_shortcodes/button.html b/layouts/_shortcodes/button.html
index a733166..d96f1a0 100644
--- a/layouts/_shortcodes/button.html
+++ b/layouts/_shortcodes/button.html
@@ -3,3 +3,4 @@
{{ $src := .Get "src" -}}
{{ $text := .Get "text" -}}
{{ $text }}
+{{- /* chomp trailing newline */ -}}
diff --git a/layouts/_shortcodes/file.html b/layouts/_shortcodes/file.html
index c8d7e57..b1dd692 100644
--- a/layouts/_shortcodes/file.html
+++ b/layouts/_shortcodes/file.html
@@ -34,3 +34,4 @@
{{ end -}}
{{ $text }}
+{{- /* chomp trailing newline */ -}}
diff --git a/layouts/_shortcodes/img.html b/layouts/_shortcodes/img.html
index dde693f..315926a 100644
--- a/layouts/_shortcodes/img.html
+++ b/layouts/_shortcodes/img.html
@@ -91,4 +91,4 @@
{{ with $link }}{{ end -}}
-{{- if $link }}{{ end }}
+{{- if $link }}{{ end -}}
diff --git a/layouts/_shortcodes/math.html b/layouts/_shortcodes/math.html
index 7ca55f7..459b8ff 100644
--- a/layouts/_shortcodes/math.html
+++ b/layouts/_shortcodes/math.html
@@ -1 +1,2 @@
${{ .Inner }}$
+{{- /* chomp trailing newline */ -}}
diff --git a/layouts/_shortcodes/reflink.html b/layouts/_shortcodes/reflink.html
index f2bf2b3..62613e9 100644
--- a/layouts/_shortcodes/reflink.html
+++ b/layouts/_shortcodes/reflink.html
@@ -1 +1 @@
-{{ with site.GetPage (.Get 0) }}{{ .Title }}{{ end }}
+{{ with site.GetPage (.Get 0) }}{{ .Title }}{{ end -}}