From 90e1777fe77f9e1c7552efd4ce3e18e384468f32 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 9 May 2025 08:59:59 +0800 Subject: chore: clean head tag According to getoutofmyhead.dev, I removed unnecessary meta tags and link tags, and also made other improvements. - remove twitter cards - remove x-ua-compatible tag - remove favicon and apple-touch-icon touch (only related image files presented in root directory will work just fine) - use one single link tag to import Google fonts - move umami code to a partial - simplify link preview tags by using variables instead of multiple if checks --- layouts/partials/head.html | 24 ++----------------- layouts/partials/head/css.html | 17 +++----------- layouts/partials/head/siteinfo.html | 45 +++++++++++++----------------------- layouts/partials/head/umami.html | 11 +++++++++ static/apple-touch-icon.png | Bin 0 -> 2980 bytes static/favicon.ico | Bin 0 -> 200116 bytes static/favicon.png | Bin 2980 -> 0 bytes 7 files changed, 32 insertions(+), 65 deletions(-) create mode 100644 layouts/partials/head/umami.html create mode 100644 static/apple-touch-icon.png create mode 100644 static/favicon.ico delete mode 100644 static/favicon.png diff --git a/layouts/partials/head.html b/layouts/partials/head.html index d289909e..10cd1c0d 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,28 +1,8 @@ - {{ hugo.Generator }} - - - - - - + {{ hugo.Generator }} {{ partial "head/siteinfo" . }} {{ partial "head/css" . }} - - - - - - {{ .Site.Params.extraHead | safeHTML }} + {{ partial "head/umami" . }} diff --git a/layouts/partials/head/css.html b/layouts/partials/head/css.html index def65db6..6777e5ad 100644 --- a/layouts/partials/head/css.html +++ b/layouts/partials/head/css.html @@ -1,18 +1,7 @@ - - - - - + + + {{ range .Site.Params.extraCSSFiles -}} diff --git a/layouts/partials/head/siteinfo.html b/layouts/partials/head/siteinfo.html index c5c355e8..64c14506 100644 --- a/layouts/partials/head/siteinfo.html +++ b/layouts/partials/head/siteinfo.html @@ -1,39 +1,26 @@ - -{{- if .IsHome -}} -{{ .Site.Title }} - - - - -{{- else -}} -{{ .Title }} - - - - -{{- end }} - -{{- if .Params.album -}} - -{{- else -}} - -{{ end }} + +{{- $isHome := .IsHome -}} +{{- $title := cond $isHome .Site.Title .Title -}} +{{- $description := cond $isHome .Site.Params.description (default .Summary .Description | plainify) -}} +{{- $ogType := cond $isHome "website" "article" -}} +{{- $image := cond (isset .Params "banner") .Params.banner .Site.Params.favicon -}} - -{{- if .Site.Params.favicon -}} - - - -{{- end -}} +{{ $title }} + + + + + + + + + - -{{ if .Site.Params.TwitterCards }}{{ template "_internal/twitter_cards.html" . }}{{ end }} - diff --git a/static/apple-touch-icon.png b/static/apple-touch-icon.png new file mode 100644 index 00000000..04dd1341 Binary files /dev/null and b/static/apple-touch-icon.png differ diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 00000000..1b116908 Binary files /dev/null and b/static/favicon.ico differ diff --git a/static/favicon.png b/static/favicon.png deleted file mode 100644 index 04dd1341..00000000 Binary files a/static/favicon.png and /dev/null differ -- cgit v1.2.3