diff --git a/hugo.toml.example b/hugo.toml.example index cfe3693..4a1db72 100644 --- a/hugo.toml.example +++ b/hugo.toml.example @@ -83,7 +83,8 @@ enableEmoji = true readTimeSeparator = "CHANGE ME READ TIME" # legacyLayout = false shareSocial = true - + # googleTagManager = "GTM-XXXXXXXX" + [[params.socialLinks]] name = "mastodon" url = "https://joinmastodon.org/" diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index d388fc7..88e18e3 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,6 +1,7 @@
+{{- if .Site.Params.googleTagManager -}}{{- partial "googleTagManager_head.html" . -}}{{- end -}} {{- partial "analytics.html" . -}} {{- partial "site-meta.html" -}} {{ $author := (.Params.author | default .Site.Params.author.name) -}} @@ -25,29 +26,30 @@ {{- block "head" . -}}{{- end -}} {{- if templates.Exists "partials/extra-head.html" -}}{{- partial "extra-head.html" . -}}{{- end -}} - {{- block "header" . -}}{{ end -}} - {{- block "main" . -}}{{ end -}} - {{- block "footer" . -}}{{ end }} - {{- partial "scroll-to-top.html" . }} - {{- $main := resources.Get "js/main.js" -}} - {{- if .Site.Params.code_copy_button | default true -}} - {{ $codeCopy := resources.Get "js/code-copy.js" -}} - {{ $script := slice $main $codeCopy | resources.Concat "js/bundle.js" | minify | fingerprint -}} - - {{- else -}} - {{ $script := $main | minify | fingerprint -}} - - {{- end -}} - {{- if and (not (eq .Site.Params.shareSocial nil)) (.Site.Params.shareSocial) -}} - {{ $linkshare := resources.Get "js/link-share.js" | minify | fingerprint -}} - - {{- end -}} - {{- range .Params.custom_js -}} - {{ $c_js := resources.Get . | minify | fingerprint -}} - - {{- end }} - {{- partial "mathjax.html" . -}} - {{- if templates.Exists "partials/extra-foot.html" -}}{{- partial "extra-foot.html" . -}}{{- end }} +{{- if .Site.Params.googleTagManager -}}{{- partial "googleTagManager_body.html" . -}}{{- end -}} +{{- block "header" . -}}{{ end -}} +{{- block "main" . -}}{{ end -}} +{{- block "footer" . -}}{{ end }} +{{- partial "scroll-to-top.html" . }} +{{- $main := resources.Get "js/main.js" -}} +{{- if .Site.Params.code_copy_button | default true -}} + {{ $codeCopy := resources.Get "js/code-copy.js" -}} + {{ $script := slice $main $codeCopy | resources.Concat "js/bundle.js" | minify | fingerprint -}} + +{{- else -}} + {{ $script := $main | minify | fingerprint -}} + +{{- end -}} +{{- if and (not (eq .Site.Params.shareSocial nil)) (.Site.Params.shareSocial) -}} +{{ $linkshare := resources.Get "js/link-share.js" | minify | fingerprint -}} + +{{- end -}} +{{- range .Params.custom_js -}} +{{ $c_js := resources.Get . | minify | fingerprint -}} + +{{- end }} +{{- partial "mathjax.html" . -}} +{{- if templates.Exists "partials/extra-foot.html" -}}{{- partial "extra-foot.html" . -}}{{- end }} diff --git a/layouts/partials/googleTagManager_body.html b/layouts/partials/googleTagManager_body.html new file mode 100644 index 0000000..0031b45 --- /dev/null +++ b/layouts/partials/googleTagManager_body.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/layouts/partials/googleTagManager_head.html b/layouts/partials/googleTagManager_head.html new file mode 100644 index 0000000..8648b01 --- /dev/null +++ b/layouts/partials/googleTagManager_head.html @@ -0,0 +1 @@ + \ No newline at end of file