{{ $scr := .Scratch }} {{/* EXTENSIBILITY HOOK: HEAD-START */}} {{ partial "functions/get_hook" (dict "hook" "head-start" "context" .) }} {{ if .Params.private }} {{- end -}} {{/* Attempt to load superuser. */}} {{ $superuser_name := "" }} {{ $superuser_username := "" }} {{ $superuser_role := "" }} {{ range first 1 (where (where site.Pages "Section" "authors") "Params.superuser" true) }} {{ $superuser_name = .Title }} {{ $superuser_username = path.Base .File.Dir }} {{ $superuser_role = .Params.role }} {{ end }} {{ $scr.Set "superuser_username" $superuser_username }}{{/* Set superuser globally for page_author.html. */}} {{ with $superuser_name }}{{ end }} {{/* Generate page description. */}} {{ $desc := "" }} {{ if .Params.summary }} {{ $desc = .Params.summary }} {{ else if .Params.abstract }} {{ $desc = .Params.abstract }} {{ else if .IsPage }} {{ $desc = .Summary }} {{ else if site.Params.marketing.seo.description }} {{ $desc = site.Params.marketing.seo.description }} {{ else }} {{ $desc = $superuser_role }} {{ end }} {{ range .Translations }} {{ end }} {{/* Hugo Blox Color Theme Initialization */}} {{ $theme_name := (lower site.Params.appearance.color) | default "blue" }} {{ $theme_path := printf "css/themes/%s.css" $theme_name }} {{ if not (fileExists (printf "assets/%s" $theme_path)) }} {{ errorf "The specified color theme `%s.css` was not found in `assets/css/themes/`. Either install your custom color theme in the folder or set the `color` theme value in `params.yaml` to an existing theme such as `blue`." $theme_name }} {{ else }} {{ $theme_css := resources.Get $theme_path | minify }} {{ end }} {{/* Style */}} {{ if ne (os.Getenv "HUGO_BLOX_POSTCSS") "true" }} {{ $styles := resources.Get "dist/wc.min.css" | fingerprint "sha256" }} {{ else }} {{ $options := dict "inlineImports" true }} {{ $styles := resources.Get "css/styles.css" }} {{ $styles = $styles | resources.PostCSS $options }} {{ if hugo.IsProduction }} {{ $styles = $styles | minify | fingerprint "sha256" | resources.PostProcess }} {{ end }} {{ end }} {{/* Load community blox styles */}} {{ $hb_community_styles := resources.Match "dist/community/blox/**.css" }} {{ with $hb_community_styles }} {{ $hb_community_styles = $hb_community_styles | resources.Concat "css/community-hugo-blox.css" }} {{- if hugo.IsProduction -}} {{- $hb_community_styles = $hb_community_styles | minify | fingerprint "sha256" -}} {{- end -}} {{ end }} {{ if fileExists "assets/css/custom.css" }} {{ $styles := resources.Get "css/custom.css" | minify | fingerprint "sha256" }} {{ end }} {{/* Analytics & Verification */}} {{/* !CACHED! All analytics and verification code is at site level */}} {{ partialCached "blox-analytics/index" . }} {{/* RSS Feed */}} {{ with .OutputFormats.Get "RSS" }} {{ end }} {{/* Progressive Web App (PWA) Icon */}} {{/* Get page image for sharing. */}} {{ $sharing_image := resources.GetMatch (path.Join "media" "sharing.*") }} {{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }} {{ $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") $avatar_image) }} {{/* Match image processing in About widget to prevent generating more images than necessary. */}} {{ $og_image = ($avatar_image.Fill "270x270 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 */}} {{ $og_image = (partialCached "functions/get_logo" (dict "constraint" "fit" "size" 300)).Permalink }} {{ $twitter_card = "summary" }} {{ else }} {{ $og_image = (partial "functions/get_site_icon" 512).Permalink }} {{ $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}" site.Title }} {{ else }} {{ $title = .Title | default site.Title }} {{ if ne $title site.Title }}{{ $title = printf "%s | %s" $title site.Title }}{{ end }} {{ end }} {{ with site.Params.marketing.seo.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}} {{/* Load font theme */}} {{ $font_family := "Inter var" }} {{ $font_file := "" }} {{ $font_type := "" }} {{ if eq site.Params.appearance.font "serif" }} {{ $font_file = "RobotoSlab-VariableFont_wght.ttf" }} {{ $font_type = "truetype" }} {{else}} {{ $font_file = "Inter.var.woff2" }} {{ $font_type = "woff2" }} {{end}} {{ $font := resources.Get (printf "dist/font/%s" $font_file) }} {{ 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 }} {{/* Exception for SVG as Hugo doesn't yet support image processing on SVG. */}} {{ if ne $bg_img.MediaType.SubType "svg" }} {{ $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" . -}} {{/* Load Third-Party Libraries */}} {{ partial "libraries.html" . }} {{ $js_license := printf "/*! Hugo Blox Builder Tailwind UI v%s | https://hugoblox.com/ */\n" site.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/hugo-blox-builder/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_academic := resources.Get "js/hb-code-copy.js" | js.Build (dict "targetPath" (printf "js/wow-core-%s.js" .Lang ) "params" $js_params) }} {{ $js_academic := $js_academic | 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_bundle := slice $js_bundle_head $js_academic $js_theme $js_lang $js_nav $js_sidebar | resources.Concat (printf "js/hugo-blox-%s.min.js" .Lang) }} {{- if hugo.IsProduction -}} {{ $js_bundle = $js_bundle | fingerprint "sha256" }} {{- end -}} {{/* EXTENSIBILITY HOOK: HEAD-END */}} {{ partial "functions/get_hook" (dict "hook" "head-end" "context" .) }}