diff --git a/config.toml b/config.toml
index 13506671..e3c7bd62 100644
--- a/config.toml
+++ b/config.toml
@@ -2,4 +2,4 @@
[module.hugoVersion]
extended = true
min = "0.87.0"
-max = "0.147.0"
\ No newline at end of file
+max = "0.147.1"
\ No newline at end of file
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 27ca17d6..46f47769 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -72,7 +72,7 @@
{{ $bundleJS := $assets.Get "js" | resources.Concat "js/main.bundle.js" | resources.Minify | resources.Fingerprint
"sha512" }}
{{ end }}
{{ if not .Site.Params.disableImageZoom | default true }}
diff --git a/layouts/shortcodes/gallery.html b/layouts/shortcodes/gallery.html
index c01b48f8..31d9bc9b 100644
--- a/layouts/shortcodes/gallery.html
+++ b/layouts/shortcodes/gallery.html
@@ -1,5 +1,31 @@
{{ $id := delimit (slice "gallery" (partial "functions/uid.html" .)) "-" }}
- {{ .Inner }}
-
\ No newline at end of file
+ {{ $page := .Page }}
+
+ {{/* find all img tags */}}
+ {{ $imgTagRegex := `
]*>` }}
+ {{ $imgTags := findRE $imgTagRegex .Inner }}
+ {{ $newContent := .Inner }}
+
+ {{ range $imgTags }}
+ {{ $imgTag := . }}
+ {{/* extract src attribute */}}
+ {{ $srcRegex := `src=['"]([^'"]+)['"]` }}
+ {{ $srcMatches := findRESubmatch $srcRegex $imgTag }}
+
+ {{ if $srcMatches }}
+ {{ $srcFull := index (index $srcMatches 0) 0 }}
+ {{ $src := index (index $srcMatches 0) 1 }}
+
+ {{ $resource := $page.Resources.GetMatch $src }}
+ {{ if $resource }}
+ {{ $newSrc := printf `src="%s"` $resource.RelPermalink }}
+ {{ $newImg := replace $imgTag $srcFull $newSrc }}
+ {{ $newContent = replace $newContent $imgTag $newImg }}
+ {{ end }}
+ {{ end }}
+ {{ end }}
+
+ {{ $newContent | safeHTML }}
+
diff --git a/layouts/shortcodes/github.html b/layouts/shortcodes/github.html
index 56146975..484d7e90 100644
--- a/layouts/shortcodes/github.html
+++ b/layouts/shortcodes/github.html
@@ -4,6 +4,7 @@
{{- $githubColors := .Site.Data.githubColors -}}
{{- with $githubData -}}
+