From 97020701977b60bed4669dbdca741bfad3475b30 Mon Sep 17 00:00:00 2001 From: Ilja Radusch Date: Fri, 12 Sep 2025 17:45:52 +0200 Subject: [PATCH 1/5] Allow images in resource folder and resize for mobile --- layouts/_default/list.html | 9 ++++++++- layouts/_default/shortblock.html | 9 ++++++++- layouts/_default/single.html | 24 ++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index fec6ecf..10500ab 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -7,7 +7,14 @@

{{ .Title }}

{{- if .Params.image }} - {{ .Params.image_alt }} + + {{- $alt := .Params.image_alt -}} + {{- with $img := resources.Get .Params.image -}} + {{- $alt -}} + {{- else -}} + {{- $alt -}} + {{- end -}} + {{ end }} {{ range .RegularPages }} diff --git a/layouts/_default/shortblock.html b/layouts/_default/shortblock.html index f85b0fb..93a9d16 100644 --- a/layouts/_default/shortblock.html +++ b/layouts/_default/shortblock.html @@ -1,6 +1,13 @@
- {{ .Params.image_alt }} + + {{- $alt := .Params.image_alt -}} + {{- with $img := resources.Get .Params.image -}} + {{- $alt -}} + {{- else -}} + {{- $alt -}} + {{- end -}} +

{{ .Title }}

{{ if .Site.Params.show_post_dates | default true }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 1a60c49..5bd6fd5 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -8,8 +8,28 @@

{{ .Title }}

{{ partial "tags.html" . }} - {{- if .Params.image }} - {{ .Params.image_alt }} + {{- if .Params.image -}} + + {{- $alt := .Title -}} + {{- $img := resources.Get .Params.image -}} + {{- with $img -}} + {{ $image_options := $.Site.Params.image_options | default "webp q90 lanczos photo" -}} + + {{ range $width := slice 1920 1600 1366 900 600 360 }} + {{ if le $width $img.Width }} + {{- with $img.Resize ( printf "%dx %s" $width $image_options ) }} + + {{- end }} + {{- end }} + {{- end }} + {{- with $img.Resize ( printf "%dx%d %s" $img.Width $img.Height $image_options ) -}} + {{ $alt }} + {{- end -}} + + {{- else -}} + {{ .Params.image_alt }} + {{- end -}} + {{ end }} {{- .Content }} From 55cbca6b33f77cd1dd72992b9f7b3ba3f2523fc5 Mon Sep 17 00:00:00 2001 From: Ilja Radusch Date: Sat, 13 Sep 2025 20:57:50 +0200 Subject: [PATCH 2/5] Optimized loading --- layouts/partials/scripts.html | 32 +++++++++++++++++++++++------ static/css/font-source-sans-pro.css | 8 ++++---- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 381dc64..0cf9476 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -1,6 +1,26 @@ - - - - - - +{{/* Bundle all JavaScript files for better performance */}} +{{ $js := slice }} +{{ $js = $js | append (resources.Get "js/jquery.min.js") }} +{{ $js = $js | append (resources.Get "js/jquery.dropotron.min.js") }} +{{ $js = $js | append (resources.Get "js/browser.min.js") }} +{{ $js = $js | append (resources.Get "js/breakpoints.min.js") }} +{{ $js = $js | append (resources.Get "js/util.js") }} +{{ $js = $js | append (resources.Get "js/main.js") }} + +{{ $bundle := $js | resources.Concat "js/bundle.js" }} +{{ with $bundle }} + {{$opts := dict + "minify" (not hugo.IsDevelopment) + "sourceMap" (cond hugo.IsDevelopment "external" "") + "targetPath" "js/bundle.js" + }} + {{ with . | js.Build $opts }} + {{ if hugo.IsDevelopment }} + + {{ else }} + {{ with . | fingerprint }} + + {{ end }} + {{ end }} + {{ end }} +{{ end }} diff --git a/static/css/font-source-sans-pro.css b/static/css/font-source-sans-pro.css index c15f5ef..f59fa7e 100644 --- a/static/css/font-source-sans-pro.css +++ b/static/css/font-source-sans-pro.css @@ -2,27 +2,27 @@ font-family:"Source Sans Pro"; font-style:normal; font-weight:300; - font-display:auto; + font-display:swap; src:url(../webfonts/SourceSansPro-Light.ttf); } @font-face{ font-family:"Source Sans Pro"; font-style:italic; font-weight:300; - font-display:auto; + font-display:swap; src:url(../webfonts/SourceSansPro-LightItalic.ttf); } @font-face{ font-family:"Source Sans Pro"; font-style:normal; font-weight:600; - font-display:auto; + font-display:swap; src:url(../webfonts/SourceSansPro-SemiBold.ttf); } @font-face{ font-family:"Source Sans Pro"; font-style:italic; font-weight:600; - font-display:auto; + font-display:swap; src:url(../webfonts/SourceSansPro-SemiBoldItalic.ttf); } \ No newline at end of file From ff4bd76b91c19ac53f843d86cd8f8e4d9f29ad51 Mon Sep 17 00:00:00 2001 From: Ilja Radusch Date: Sat, 13 Sep 2025 21:07:27 +0200 Subject: [PATCH 3/5] Optimized image sizes --- layouts/_default/list.html | 64 +++++++++++++++++++-------- layouts/_default/shortblock.html | 74 ++++++++++++++++++++++---------- layouts/_default/single.html | 2 +- 3 files changed, 98 insertions(+), 42 deletions(-) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 10500ab..faf9ed1 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,24 +1,50 @@ {{ define "main" }} -
-

{{ .Title }}

- {{ with .Description -}} -

{{ . }}

- {{- end }} -
- - {{- if .Params.image }} - - {{- $alt := .Params.image_alt -}} - {{- with $img := resources.Get .Params.image -}} - {{- $alt -}} - {{- else -}} - {{- $alt -}} - {{- end -}} - +
+

{{ .Title }}

+ {{ with .Description }} +

{{ . }}

{{ end }} +
- {{ range .RegularPages }} - {{ .Render "shortblock" }} - {{ end }} + {{- if .Params.image }} + {{- $alt := .Params.image_alt | default .Title -}} + {{- with $img := resources.Get .Params.image }} + {{ $image_options := $.Site.Params.image_options | default "webp q85 lanczos photo" }} + + {{- $breakpoints := slice 1920 1600 1366 900 600 360 -}} + {{- range $bp := $breakpoints }} + {{- if le $bp .Width }} + {{- with .Resize (printf "%dx %s" $bp $image_options) }} + + {{- end }} + {{- end }} + {{- end }} + + {{- /* Fallback: full-sized optimized image */ -}} + {{- with .Resize (printf "%dx %s" .Width $image_options) }} + {{ $alt }} + {{- end }} + + {{- else }} + + {{ $alt }} + + {{- end }} + {{ end }} + {{ range .RegularPages }} + {{ .Render "shortblock" }} + {{ end }} {{ end }} diff --git a/layouts/_default/shortblock.html b/layouts/_default/shortblock.html index 93a9d16..2a3adac 100644 --- a/layouts/_default/shortblock.html +++ b/layouts/_default/shortblock.html @@ -1,25 +1,55 @@
-
- - {{- $alt := .Params.image_alt -}} - {{- with $img := resources.Get .Params.image -}} - {{- $alt -}} - {{- else -}} - {{- $alt -}} - {{- end -}} - -
-

{{ .Title }}

- {{ if .Site.Params.show_post_dates | default true }} - {{- with .Date }}{{ end }} - {{ end }} -

- {{ with .Description }} - {{- . }} - {{- else }} - {{- .Summary }} - {{- end }} -

-
+
+ + {{- $alt := .Params.image_alt | default .Title -}} + {{- with $img := resources.Get .Params.image }} + {{ $image_options := $.Site.Params.image_options | default "webp q85 lanczos photo" }} + {{- $breakpoints := slice 800 600 400 300 -}} + {{- $orig := $img -}} + + + {{- range $bp := $breakpoints }} + {{- if le $bp $orig.Width }} + {{- with $orig.Resize (printf "%dx %s" $bp $image_options) }} + + {{- end }} + {{- end }} + {{- end }} + + {{- /* Fallback main image (max 800px) */ -}} + {{- with $orig.Resize (printf "800x %s" $image_options) }} + {{ $alt }} + {{- end }} + + {{- else }} + {{ $alt }} + {{- end }} + + +
+

{{ .Title }}

+ {{ if .Site.Params.show_post_dates | default true }} + {{- with .Date }}{{ end }} + {{ end }} +

+ {{ with .Description }} + {{- . }} + {{- else }} + {{- .Summary }} + {{- end }} +

+
diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 5bd6fd5..ed11b85 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -13,7 +13,7 @@

{{ .Title }}

{{- $alt := .Title -}} {{- $img := resources.Get .Params.image -}} {{- with $img -}} - {{ $image_options := $.Site.Params.image_options | default "webp q90 lanczos photo" -}} + {{ $image_options := $.Site.Params.image_options | default "webp q85 lanczos photo" -}} {{ range $width := slice 1920 1600 1366 900 600 360 }} {{ if le $width $img.Width }} From 74c18bc0bf83863a2f092a31c353975526535c5e Mon Sep 17 00:00:00 2001 From: Ilja Radusch Date: Sat, 13 Sep 2025 23:32:11 +0200 Subject: [PATCH 4/5] do not build javascript --- layouts/partials/scripts.html | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 0cf9476..9141324 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -1,26 +1,11 @@ -{{/* Bundle all JavaScript files for better performance */}} -{{ $js := slice }} -{{ $js = $js | append (resources.Get "js/jquery.min.js") }} -{{ $js = $js | append (resources.Get "js/jquery.dropotron.min.js") }} -{{ $js = $js | append (resources.Get "js/browser.min.js") }} -{{ $js = $js | append (resources.Get "js/breakpoints.min.js") }} -{{ $js = $js | append (resources.Get "js/util.js") }} -{{ $js = $js | append (resources.Get "js/main.js") }} +{{- $js := slice + (resources.Get "js/jquery.min.js") + (resources.Get "js/jquery.dropotron.min.js") + (resources.Get "js/browser.min.js") + (resources.Get "js/breakpoints.min.js") + (resources.Get "js/util.js") + (resources.Get "js/main.js") +-}} -{{ $bundle := $js | resources.Concat "js/bundle.js" }} -{{ with $bundle }} - {{$opts := dict - "minify" (not hugo.IsDevelopment) - "sourceMap" (cond hugo.IsDevelopment "external" "") - "targetPath" "js/bundle.js" - }} - {{ with . | js.Build $opts }} - {{ if hugo.IsDevelopment }} - - {{ else }} - {{ with . | fingerprint }} - - {{ end }} - {{ end }} - {{ end }} -{{ end }} +{{- $bundle := $js | resources.Concat "js/bundle.js" | resources.Minify | resources.Fingerprint -}} + From f764db68e50f38be715118a71467043b54942785 Mon Sep 17 00:00:00 2001 From: Ilja Radusch Date: Sat, 13 Sep 2025 23:32:31 +0200 Subject: [PATCH 5/5] Allow for header image --- assets/sass/main.scss | 3 +++ layouts/partials/head/head.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/sass/main.scss b/assets/sass/main.scss index 96655b0..f919b82 100644 --- a/assets/sass/main.scss +++ b/assets/sass/main.scss @@ -1678,4 +1678,7 @@ } +{{ with (index ( index .Site.Data .Site.Language.Lang | default .Site.Data ) "homepage" "header" "image") -}} + $header-image: "{{- . -}}"; +{{- end }} @import 'custom.scss'; diff --git a/layouts/partials/head/head.html b/layouts/partials/head/head.html index bfaa21c..7febd73 100644 --- a/layouts/partials/head/head.html +++ b/layouts/partials/head/head.html @@ -2,7 +2,7 @@ {{ $style := resources.Get "sass/main.scss" | resources.ExecuteAsTemplate "main.scss" . | css.Sass $options }} {{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ .Title }} | {{ .Site.Title }}{{ end }} - + {{- partial "analytics/google-tag-manager/head.html" . -}} {{- partial "head/custom.html" . -}}