summaryrefslogtreecommitdiff
path: root/layouts/_partials/head.html
diff options
context:
space:
mode:
authorNicholas Johnson <>2026-09-18 00:00:00 +0000
committerNicholas Johnson <>2026-09-19 19:00:02 -0400
commitd4ae7d9c03015778cdacbcbde52041b9dcbad7d92497529e9d460ddf42dcdb50 (patch)
tree6e3bc6848e9bc0c859fed43b8f2931b2ef2504c6f5696510c19c9b08466ba97f /layouts/_partials/head.html
parent40d957cfbe3c4791145a35cba1004a6ea30b45ac9e0dbc4eee3577c2d981ee04 (diff)
downloadhugo-theme-journal-d4ae7d9c03015778cdacbcbde52041b9dcbad7d92497529e9d460ddf42dcdb50.tar.gz
hugo-theme-journal-d4ae7d9c03015778cdacbcbde52041b9dcbad7d92497529e9d460ddf42dcdb50.zip
Handle missing optional site files gracefully
Two site files the theme reads were assumed to exist. A site without templates/logo.txt got an empty preformatted block at the top of every page in both output formats, styled with the logo's margins, rather than no logo at all. A typo in params.custom_css produced a nil pointer error naming only the template line, since the result of resources.Get was used without checking it. Skip the header entirely when there is no logo, and report a missing stylesheet by name. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'layouts/_partials/head.html')
-rw-r--r--layouts/_partials/head.html12
1 files changed, 6 insertions, 6 deletions
diff --git a/layouts/_partials/head.html b/layouts/_partials/head.html
index 5a1f89a..0c5a796 100644
--- a/layouts/_partials/head.html
+++ b/layouts/_partials/head.html
@@ -8,12 +8,12 @@
{{ if $.Site.Params.keywords }}
<meta name="keywords" content="{{ $.Site.Params.keywords }}">
{{- end -}}
- {{ if .Site.Params.custom_css -}}
- {{ range .Site.Params.custom_css }}
- <link rel="stylesheet" type="text/css" href="{{ (resources.Get . | minify | fingerprint).RelPermalink }}">
- {{- end -}}
- {{ else }}
- <link rel="stylesheet" type="text/css" href="{{ (resources.Get "static/css/style.css" | minify | fingerprint).RelPermalink }}">
+ {{ range .Site.Params.custom_css | default (slice "static/css/style.css") }}
+ {{- with resources.Get . }}
+ <link rel="stylesheet" type="text/css" href="{{ (. | minify | fingerprint).RelPermalink }}">
+ {{- else }}
+ {{- errorf "stylesheet %q listed in params.custom_css was not found in the assets directory" . }}
+ {{- end }}
{{- end -}}
{{ with .OutputFormats.Get "Atom" }}
<link rel="alternate" type="application/atom+xml" href="{{ .RelPermalink }}" title="{{ $.Site.Title }}">