{{- /*
Head Partial - Comprehensive head section template
This partial consolidates all head-related content including:
- META: Meta tags for SEO, Open Graph, Twitter Cards, and app metadata
- LINK: Favicon, canonical links, RSS feeds, and CSS stylesheet loading
- SEO: Schema.org structured data for pages and homepage
- SCRIPT: Early-loaded scripts (e.g., theme color scheme detection)
Called from: layouts/baseof.html
*/ -}}
{{- $fingerprint := .Site.Store.Get "fingerprint" -}}
{{- $cdn := .Site.Store.Get "cdn" | default dict -}}
{{- /* ========== META: Meta Tags ========== */ -}}
{{- $author := partial "function/get-author-map.html" .Params.author -}}
{{- $keywords := .Keywords -}}
{{- if not $keywords -}}
{{- if .IsPage | and .Params.tags -}}
{{- $keywords = .Params.tags -}}
{{- else -}}
{{- $keywords = .Site.Params.keywords -}}
{{- end -}}
{{- end -}}
{{- with $keywords -}}
{{- end -}}
{{- template "_internal/schema.html" . -}}
{{- template "_internal/opengraph.html" . -}}
{{- template "_internal/twitter_cards.html" . -}}
{{- with .Site.Params.social.Twitter -}}
{{- end -}}
{{- with .Site.Params.app.themeColor -}}
{{- $color := . -}}
{{- if ne (len $color) 2 -}}
{{- $color = dict "light" . "dark" . -}}
{{- end -}}
{{- end -}}
{{- with .Site.Params.app.tileColor -}}
{{- end -}}
{{- /* Mastodon Verification */ -}}
{{- with .Site.Params.social.Mastodon -}}
{{- $id := "" -}}
{{- $prefix := "https://mastodon.social/" -}}
{{- if reflect.IsMap . -}}
{{- $id = .Id | default .id -}}
{{- $prefix = .Prefix | default .prefix | default $prefix -}}
{{- end -}}
{{- if $id | and $prefix -}}
{{- $link := printf "%s/%s" $prefix $id -}}
{{- $email := printf "%s@%s" (strings.TrimPrefix "@" $id) (urls.Parse $prefix).Host -}}
{{- end -}}
{{- end -}}
{{- /* ========== LINK: Favicon, Canonical, Feeds, Stylesheets ========== */ -}}
{{- $title := printf "%s %s %s" .Title .Site.Params.titleDelimiter .Site.Title -}}
{{- if .IsHome -}}
{{- $title = .Site.Title -}}
{{- end -}}
{{- /* Favicon links */ -}}
{{- if not .Site.Params.app.noFavicon -}}
{{- $relURL := relURL "" -}}
{{- with .Site.Params.app.svgFavicon -}}
{{- else -}}
{{- end -}}
{{- with .Site.Params.app.iconColor -}}
{{- end -}}
{{- if eq .Site.Params.enablePWA true -}}
{{- end -}}
{{- end -}}
{{- /* Canonical and pagination links */ -}}
{{- with .Prev -}}
{{- end -}}
{{- with .Next -}}
{{- end -}}
{{- /* Alternative output formats (Atom, RSS, etc.) */ -}}
{{- range .AlternativeOutputFormats -}}
{{- printf `` .Rel .MediaType.Type .Permalink $title | safeHTML -}}
{{- end -}}
{{- /* JSON Feed support */ -}}
{{- with .OutputFormats.Get "jsonfeed" -}}
{{- end -}}
{{- /* Core stylesheets */ -}}
{{- /* Config CSS */ -}}
{{- $options := dict "Source" "scss/config.template.scss" "Template" "scss/config.scss" "Fingerprint" $fingerprint -}}
{{- $toCSS := dict "targetPath" "css/config.min.css" "enableSourceMap" true -}}
{{- $options = dict "Context" . "ToCSS" $toCSS | merge $options -}}
{{- partial "plugin/style.html" $options -}}
{{- /* Theme CSS */ -}}
{{- $options := dict "Source" "scss/main.scss" "Fingerprint" $fingerprint -}}
{{- $toCSS := dict "targetPath" "css/main.min.css" "enableSourceMap" true -}}
{{- $options = dict "Context" . "ToCSS" $toCSS | merge $options -}}
{{- partial "plugin/style.html" $options -}}
{{- /* Font Awesome Icons */ -}}
{{- $source := $cdn.fontawesomeFreeCSS | default "lib/fontawesome-free/all.min.css" -}}
{{- $options := dict "Source" $source "Fingerprint" $fingerprint "Preload" true -}}
{{- partial "plugin/style.html" $options -}}
{{- /* Animate.css Animation Library */ -}}
{{- $source := $cdn.animateCSS | default "lib/animate/animate.min.css" -}}
{{- $options := dict "Source" $source "Fingerprint" $fingerprint "Preload" true -}}
{{- partial "plugin/style.html" $options -}}
{{- /* ========== SEO: Structured Data (Schema.org) ========== */ -}}
{{- $params := partial "function/params.html" -}}
{{- /* Search Engine Verification */ -}}
{{- with .Site.Params.verification.google -}}
{{- end -}}
{{- with .Site.Params.verification.bing -}}
{{- end -}}
{{- with .Site.Params.verification.yandex -}}
{{- end -}}
{{- with .Site.Params.verification.pinterest -}}
{{- end -}}
{{- with .Site.Params.verification.baidu -}}
{{- end -}}
{{- with .Site.Params.verification.so -}}
{{- end -}}
{{- with .Site.Params.verification.sogou -}}
{{- end -}}
{{- /* Homepage Structured Data */ -}}
{{- if .IsHome -}}
{{- /* Page (Article) Structured Data */ -}}
{{- else if .IsPage -}}
{{- $authorName := .Site.Params.author.name | default (T "single.author") -}}
{{- with .Params.author -}}
{{- if reflect.IsMap . -}}
{{- $authorName = cond (isset . "name") .name $authorName -}}
{{- else -}}
{{- $authorName = . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- /* ========== SCRIPT: Early-Loaded Head Scripts ========== */ -}}
{{- /* Theme Color Scheme Detection (runs before page render) */ -}}
{{- $options := dict "targetPath" "js/head/color-scheme.min.js" "minify" hugo.IsProduction -}}
{{- $options := dict "defaultTheme" .Site.Params.defaulttheme | dict "params" | merge $options -}}
{{- if not hugo.IsProduction -}}
{{- $options = dict "sourceMap" "external" | merge $options -}}
{{- end -}}
{{- dict "Source" (resources.Get "js/head/color-scheme.js") "Build" $options "Fingerprint" $fingerprint | partial "plugin/script.html" -}}