{{ $scr := .Scratch }} {{/* EXTENSIBILITY HOOK: HEAD-START */}} {{ partial "functions/get_hook" (dict "hook" "head-start" "context" .) }} {{ if .Params.private }} {{- end -}} {{/* Attempt to load superuser/person from data. */}} {{ $superuser_name := "" }} {{ $superuser_slug := "" }} {{ $superuser_role := "" }} {{/* Prefer is_owner flag, fallback to slug 'me' */}} {{ $authors := partialCached "functions/get_authors_data" . site.Language.Lang }} {{ range $slug, $data := $authors }} {{ if and (not $superuser_slug) ($data.is_owner) }} {{ $superuser_slug = $slug }} {{ end }} {{ end }} {{ if and (eq $superuser_slug "") (index $authors "me") }} {{ $superuser_slug = "me" }} {{ end }} {{ if $superuser_slug }} {{ $profile := partial "functions/get_author_profile" (dict "slug" $superuser_slug) }} {{ $superuser_name = $profile.title }} {{ $superuser_role = $profile.role }} {{ end }} {{ $scr.Set "superuser_slug" $superuser_slug }}{{/* Set superuser globally for author rendering. */}} {{ with $superuser_name }}{{ end }} {{/* Generate page description. */}} {{ $desc := "" }} {{ $desc = partial "functions/get_summary" . }} {{ if site.Params.hugoblox.identity.description | and (not $desc) }} {{ $desc = site.Params.hugoblox.identity.description }} {{ end }} {{ if not $desc }} {{ $desc = $superuser_role }} {{ end }} {{ range .Translations }} {{ end }} {{/* Hugo Blox Theme Engine Initialization */}} {{/* Uses get_theme_config helper for backward-compatible config resolution */}} {{ $theme_config := partialCached "functions/get_theme_config" . "theme_config" }} {{ partial "functions/theme_generator.html" $theme_config }} {{/* Demo Theme Pack Styles (if enabled) */}} {{ if site.Params.hugoblox.header.theme_picker }} {{ partial "functions/demo_theme_styles.html" (dict "typography" $theme_config.typography "layout" $theme_config.layout) }} {{ end }} {{/* Tailwind CSS v4 Processing */}} {{/* Use templates.Defer to process CSS after all content is analyzed */}} {{ with (templates.Defer (dict "key" "tailwind-css")) }} {{ partial "css.html" . }} {{ end }} {{ if fileExists "assets/css/custom.css" }} {{ $styles := resources.Get "css/custom.css" | minify | fingerprint "sha256" }} {{ end }} {{/* Externalized init scripts for CSP-friendly head */}} {{- $hb_head := resources.Get "js/hb-head.js" | js.Build | resources.Minify -}} {{- if hugo.IsProduction -}} {{- $hb_head = $hb_head | fingerprint "sha256" -}} {{- end -}} {{/* Analytics & Verification */}} {{/* !CACHED! All analytics and verification code is at site level */}} {{ partialCached "blox-analytics/index" . }} {{/* RSS Feed */}} {{ $branding := partialCached "functions/get_branding" . "branding" }} {{ with .OutputFormats.Get "RSS" }} {{ end }} {{/* Progressive Web App (PWA) Icon - SVG preferred */}} {{ $icon := partial "functions/get_site_icon" 32 }} {{ with $icon.resource }} {{ end }} {{/* Apple Touch Icon - requires PNG */}} {{ $icon_apple := partial "functions/get_site_icon" 180 }} {{ if not $icon_apple.is_svg }} {{ with $icon_apple.resource }} {{ end }} {{ else }} {{/* SVG icon - need PNG fallback for Apple */}} {{ $icon_png := resources.Get "media/icon.png" }} {{ with $icon_png }} {{ $apple_icon := .Fill "180x180 Center" }} {{ end }} {{ end }} {{/* Get page image for sharing. */}} {{ $sharing_image := resources.GetMatch (path.Join "media" "sharing.*") }} {{ $featured_image := partial "functions/get_featured_image" . }} {{ $avatar_image := (.Resources.ByType "image").GetMatch "avatar*" }} {{ $has_logo := fileExists "assets/media/logo.png" | or (fileExists "assets/media/logo.svg") }} {{ $og_image := "" }} {{ $twitter_card := "summary_large_image" }} {{ if and (eq .Kind "term") (eq .Data.Singular "author") }} {{/* Try data-driven avatar for author term pages */}} {{ $termSlug := .Data.Term | urlize }} {{ $profile := partial "functions/get_author_profile" (dict "slug" $termSlug) }} {{ with $profile.avatar }} {{ $og_image = (.Fill "540x540 Center").Permalink }} {{ $twitter_card = "summary" }} {{ end }} {{ else if (and (eq .Kind "term") $avatar_image) }} {{ $og_image = ($avatar_image.Fill "540x540 Center").Permalink }} {{ $twitter_card = "summary" }} {{ else if $featured_image }} {{ $og_image = $featured_image.Permalink }} {{ else if $sharing_image }} {{ $og_image = $sharing_image.Permalink }} {{ else if $has_logo }} {{/* !CACHED! Can safely cache this site logo variant */}} {{ $logo_data := partialCached "functions/get_logo" (dict "constraint" "fit" "size" 300) "logo_og" }} {{ with $logo_data.resource }} {{ $og_image = .Permalink }} {{ end }} {{ $twitter_card = "summary" }} {{ else }} {{ $icon_og := partial "functions/get_site_icon" 512 }} {{ with $icon_og.resource }} {{ $og_image = .Permalink }} {{ end }} {{ $twitter_card = "summary" }} {{ end }} {{ $scr.Set "og_image" $og_image }}{{/* Set `og_image` globally for `rss.xml`. */}} {{ $title := "" }} {{ with .Params.seo.title }} {{ $title = replace . "{brand}" $branding.site_title }} {{ else }} {{ $title = .Title | default $branding.site_title }} {{ if ne $title $branding.site_title }}{{ $title = printf "%s | %s" $title $branding.site_title }}{{ end }} {{ end }} {{ with site.Params.hugoblox.identity.social.twitter }} {{ end }} {{- with $og_image -}} {{- end -}} {{ if .IsPage }} {{ if not .PublishDate.IsZero }} {{ else if not .Date.IsZero }} {{ end }} {{ if not .Lastmod.IsZero }}{{ end }} {{ else }} {{ if not .Date.IsZero }} {{ end }} {{ end }} {{ partial "jsonld/main" (dict "page" . "summary" $desc) }} {{$title}} {{/* Typography: font loading, font families, and sizes */}} {{ partial "functions/typography.html" $theme_config }} {{/* Layout tokens: radius and spacing */}} {{ partial "functions/layout_tokens.html" $theme_config }} {{ if .Params.design.background.image.filename }} {{/* See Hugo note on linking assets in styles: https://github.com/gohugoio/hugoThemes#common-permalink-issues */}} {{ $bg_img := resources.Get (printf "media/%s" .Params.design.background.image.filename) }} {{ if $bg_img }} {{ if reflect.IsImageResourceProcessable $bg_img }} {{ $bg_img = $bg_img.Fit "1920x1920 webp" }} {{ end }} {{ else }} {{ errorf "Couldn't find page background `%s` in the `assets/media/` folder - please add it." .Params.design.background.image.filename }} {{ end }} {{ end }} {{/* Init prior to auto-chunking/bundling scripts due to Hugo concurrency issues */}} {{/* !CACHED! Initialized once at site level and then cached for each page */}} {{- partialCached "init.html" . "hb_init_once" -}} {{ $js_license := printf "/*! Hugo Blox Kit Tailwind UI v%s | https://hugoblox.com/ */\n" hugo.Data.hugoblox.version }} {{ $js_license := $js_license | printf "%s/*! Copyright 2016-present George Cushen (https://georgecushen.com/) */\n" }} {{ $js_license := $js_license | printf "%s/*! License: https://github.com/HugoBlox/kit/blob/main/LICENSE.md */\n" }} {{ $js_bundle_head := $js_license | resources.FromString "js/bundle-head.js" }} {{ $i18n := dict "copy" (i18n "btn_copy") "copied" (i18n "btn_copied" | default "Copied") }} {{ $js_params := dict "hugoEnvironment" hugo.Environment "i18n" $i18n }} {{ $js_hugoblox := resources.Get "js/hb-code-copy.js" | js.Build (dict "targetPath" (printf "js/hugoblox-core-%s.js" .Lang ) "params" $js_params) }} {{ $js_hugoblox := $js_hugoblox | resources.Minify }} {{- $js_theme := resources.Get "js/hb-theme.js" | resources.Minify -}} {{- $js_lang := resources.Get "js/hb-i18n.js" | resources.Minify -}} {{- $js_nav := resources.Get "js/hb-nav.js" | resources.Minify -}} {{- $js_sidebar := resources.Get "js/hb-sidebar.js" | resources.Minify -}} {{- $js_notifier := resources.Get "js/hb-notifier.js" | js.Build (dict "targetPath" (printf "js/hb-notifier-%s.js" .Lang ) "params" $js_params) | resources.Minify -}} {{- $js_clipboard := resources.Get "js/hb-clipboard.js" | js.Build (dict "targetPath" (printf "js/hb-clipboard-%s.js" .Lang ) "params" $js_params) | resources.Minify -}} {{- $js_citation := resources.Get "js/hb-citation.js" | js.Build (dict "targetPath" (printf "js/hb-citation-%s.js" .Lang ) "params" $js_params) | resources.Minify -}} {{/* Start with the core scripts */}} {{ $js_bundle_contents := slice $js_bundle_head $js_hugoblox $js_theme $js_lang $js_nav $js_sidebar $js_notifier $js_clipboard $js_citation }} {{/* Discover and include block-specific JavaScript */}} {{- with partial "functions/get-block-scripts.html" . -}} {{ $js_bundle_contents = $js_bundle_contents | append . }} {{- end -}} {{ $js_bundle := $js_bundle_contents | resources.Concat (printf "js/hugo-blox-%s.min.js" .Lang) }} {{- if hugo.IsProduction -}} {{ $js_bundle = $js_bundle | fingerprint "sha256" }} {{- end -}} {{/* Load Third-Party Libraries */}} {{ partial "libraries.html" . }} {{/* EXTENSIBILITY HOOK: HEAD-END */}} {{ partial "functions/get_hook" (dict "hook" "head-end" "context" .) }}