diff --git a/layouts/_partials/scripts/katex.html b/layouts/_partials/scripts/katex.html
index c29b436785..193d18131a 100644
--- a/layouts/_partials/scripts/katex.html
+++ b/layouts/_partials/scripts/katex.html
@@ -11,9 +11,9 @@
       {{ $secureCSS := . | resources.Fingerprint "sha512" -}}
 
     {{ end -}}
+  {{ else -}}
+    {{ errorf "Could not retrieve css file %q from CDN. Reason: invalid KaTeX version %q." $katex_css_url $version -}}
   {{ end -}}
-{{ else -}}
-  {{ errorf "Invalid KaTeX version %s, could not retrieve this version from CDN." $version -}}
 {{ end -}}
 
 {{/* The loading of KaTeX is deferred to speed up page rendering */ -}}
@@ -26,9 +26,9 @@
       {{ $secureJS := . | resources.Fingerprint "sha512" -}}
 
     {{ end -}}
+  {{ else -}}
+    {{ errorf "Could not retrieve javascript file %q from CDN. Reason: invalid KaTeX version %q." $katex_js_url $version -}}
   {{ end -}}
-{{ else -}}
-  {{ errorf "Invalid KaTeX version %s, could not retrieve this version from CDN." $version -}}
 {{ end -}}
 
 {{/* Add support for displaying chemical equations and physical units by loading the mhchem extension: */ -}}
@@ -49,7 +49,7 @@
 {{ printf "onload='renderMathInElement(%s, %s);'" (( $.Page.Site.Params.katex.html_dom_element | default "document.body" ) | safeJS ) ( printf "%s" ( $.Page.Site.Params.katex.options | jsonify )) | safeHTMLAttr -}} >
 
     {{ end -}}
+  {{ else -}}
+    {{ errorf "Could not retrieve autorender extension %q from CDN. Reason: invalid KaTeX version %q." $katex_autorender_url $version -}}
   {{ end -}}
-{{ else -}}
-  {{ errorf "Invalid KaTeX version %s, could not retrieve this version from CDN." $version -}}
 {{ end -}}
diff --git a/layouts/_partials/scripts/mhchem.html b/layouts/_partials/scripts/mhchem.html
index 931ca4ddbb..f00d7e9da5 100644
--- a/layouts/_partials/scripts/mhchem.html
+++ b/layouts/_partials/scripts/mhchem.html
@@ -8,7 +8,7 @@
       {{ $secureJS := . | resources.Fingerprint "sha512" -}}
 
     {{ end -}}
+  {{ else -}}
+    {{ errorf "Could not retrieve mhchem extension %q from CDN. Reason: invalid KaTeX version %q." $mhchem_url $.version -}}
   {{ end -}}
-{{ else -}}
-  {{ errorf "Invalid KaTeX version %s, could not retrieve this version from CDN." .version -}}
 {{ end -}}