2023-10-24 18:31:41 +01:00
{{ $scr := .Scratch }}
< head >
< meta charset = "utf-8" / >
< meta name = "viewport" content = "width=device-width, initial-scale=1" / >
< meta http-equiv = "X-UA-Compatible" content = "IE=edge" / >
2023-11-07 23:09:38 +00:00
< meta name = "generator" content = "Hugo Blox Builder {{ site.Data.hugoblox.version }}" / >
2023-10-24 18:31:41 +01:00
{{/* EXTENSIBILITY HOOK: HEAD-START */}}
{{ partial "functions/get_hook" (dict "hook" "head-start" "context" .) }}
{{ if .Params.private }}
< meta name = "robots" content = "noindex" / >
{{- 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 }}< meta name = "author" content = "{{ . }}" / > {{ 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 }}
2024-10-16 22:43:18 +01:00
< meta name = "description" content = "{{ $desc | plainify }}" / >
2023-10-24 18:31:41 +01:00
{{ range .Translations }}
< link rel = "alternate" hreflang = "{{ .Lang }}" href = "{{ .Permalink }}" / >
{{ end }}
< link rel = "alternate" hreflang = "{{ site.LanguageCode | default " en-us " } } " href = "{{ .Permalink }}" / >
2023-11-24 14:48:34 +00:00
{{/* 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)) }}
2024-05-19 13:06:15 +01:00
{{ 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 }}
2023-11-24 14:48:34 +00:00
{{ else }}
{{ $theme_css := resources.Get $theme_path | minify }}
< link rel = "stylesheet" href = "{{ $theme_css.RelPermalink }}" / >
{{ end }}
2023-10-24 18:31:41 +01:00
{{/* Style */}}
2024-06-01 19:27:12 +01:00
{{ if ne (os.Getenv "HUGO_BLOX_POSTCSS") "true" }}
2024-12-20 10:51:02 +01:00
{{ $styles := resources.Get "dist/wc.min.css" | fingerprint "sha256" }}
2023-10-24 18:31:41 +01:00
< link href = "{{ $styles.RelPermalink }}" rel = "stylesheet" / >
{{ else }}
{{ $options := dict "inlineImports" true }}
{{ $styles := resources.Get "css/styles.css" }}
{{ $styles = $styles | resources.PostCSS $options }}
{{ if hugo.IsProduction }}
2023-10-27 20:40:09 +01:00
{{ $styles = $styles | minify | fingerprint "sha256" | resources.PostProcess }}
2023-10-24 18:31:41 +01:00
{{ end }}
< link href = "{{ $styles.RelPermalink }}" rel = "stylesheet" / >
{{ end }}
2024-04-20 22:45:32 +01:00
{{/* 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 -}}
< link href = "{{ $hb_community_styles.RelPermalink }}" rel = "stylesheet" / >
{{ end }}
2023-12-29 23:34:33 +00:00
{{ if fileExists "assets/css/custom.css" }}
{{ $styles := resources.Get "css/custom.css" | minify | fingerprint "sha256" }}
< link href = "{{ $styles.RelPermalink }}" rel = "stylesheet" / >
{{ end }}
2023-10-24 18:31:41 +01:00
< script >
2023-11-07 23:09:38 +00:00
/* Hugo Blox JS Global Init */
2023-11-09 14:58:28 +00:00
window.hbb = {
2023-10-29 09:18:33 +00:00
defaultTheme: document.documentElement.dataset.wcThemeDefault,
setDarkTheme: () => {
document.documentElement.classList.add("dark");
document.documentElement.style.colorScheme = "dark";
},
setLightTheme: () => {
document.documentElement.classList.remove("dark");
document.documentElement.style.colorScheme = "light";
}
2023-10-24 18:31:41 +01:00
}
2023-11-09 14:58:28 +00:00
console.debug(`Default Hugo Blox Builder theme is ${window.hbb.defaultTheme}`);
2023-10-29 09:18:33 +00:00
2023-10-24 18:31:41 +01:00
if ("wc-color-theme" in localStorage) {
2023-11-09 14:58:28 +00:00
localStorage.getItem("wc-color-theme") === "dark" ? window.hbb.setDarkTheme() : window.hbb.setLightTheme();
2023-10-24 18:31:41 +01:00
} else {
2023-11-09 14:58:28 +00:00
window.hbb.defaultTheme === "dark" ? window.hbb.setDarkTheme() : window.hbb.setLightTheme();
if (window.hbb.defaultTheme === "system") {
window.matchMedia("(prefers-color-scheme: dark)").matches ? window.hbb.setDarkTheme() : window.hbb.setLightTheme();
2023-10-24 18:31:41 +01:00
}
}
< / script >
< script >
2023-10-29 09:18:33 +00:00
// Apply Hugo style fixes
2023-10-24 18:31:41 +01:00
document.addEventListener('DOMContentLoaded', function () {
// Fix Hugo task list style
let checkboxes = document.querySelectorAll('li input[type=\'checkbox\'][disabled]');
checkboxes.forEach(e => {
e.parentElement.parentElement.classList.add('task-list');
});
// Fix Hugo missing < label > around checkbox and its text (fixes Lighthouse accessibility errors)
const liNodes = document.querySelectorAll('.task-list li');
liNodes.forEach(nodes => {
let textNodes = Array.from(nodes.childNodes).filter(node => node.nodeType === 3 & & node.textContent.trim().length > 1);
if (textNodes.length > 0) {
const span = document.createElement('label');
textNodes[0].after(span); // Use first text node as label
span.appendChild(nodes.querySelector('input[type=\'checkbox\']'));
span.appendChild(textNodes[0]);
}
});
});
< / script >
2023-12-29 23:34:33 +00:00
{{/* Analytics & Verification */}}
2024-05-05 22:44:12 +01:00
{{/* !CACHED! All analytics and verification code is at site level */}}
{{ partialCached "blox-analytics/index" . }}
2023-10-24 18:31:41 +01:00
{{/* RSS Feed */}}
{{ with .OutputFormats.Get "RSS" }}
< link rel = "alternate" href = "{{ .RelPermalink }}" type = "application/rss+xml" title = "{{ site.Title }}" / >
{{ end }}
{{/* Progressive Web App (PWA) Icon */}}
< link rel = "icon" type = "image/png" href = "{{ (partial " functions / get_site_icon " 32 ) . RelPermalink } } " / >
< link rel = "apple-touch-icon" type = "image/png" href = "{{ (partial " functions / get_site_icon " 180 ) . RelPermalink } } " / >
< link rel = "canonical" href = "{{ .Permalink }}" / >
{{/* 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 }}
2024-05-05 22:44:12 +01:00
{{/* !CACHED! Can safely cache this site logo variant */}}
{{ $og_image = (partialCached "functions/get_logo" (dict "constraint" "fit" "size" 300)).Permalink }}
2023-10-24 18:31:41 +01:00
{{ $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 }}
< meta property = "twitter:card" content = "{{ $twitter_card }}" / >
{{ with site.Params.marketing.seo.twitter }}
< meta property = "twitter:site" content = "@{{ . }}" / >
< meta property = "twitter:creator" content = "@{{ . }}" / >
{{ end }}
< meta property = "og:site_name" content = "{{ site.Title }}" / >
< meta property = "og:url" content = "{{ .Permalink }}" / >
< meta property = "og:title" content = "{{ $title }}" / >
< meta property = "og:description" content = "{{ $desc }}" / >
{{- with $og_image -}}
< meta property = "og:image" content = "{{ . }}" / >
< meta property = "twitter:image" content = "{{ . }}" / >
{{- end -}}
< meta property = "og:locale" content = "{{ site.LanguageCode | default " en-us " } } " / >
{{ if .IsPage }}
{{ if not .PublishDate.IsZero }}
< meta
property="article:published_time"
content="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}"
/>
{{ else if not .Date.IsZero }}
< meta property = "article:published_time" content = "{{ .Date.Format " 2006-01-02T15:04:05-07:00 " | safeHTML } } " / >
{{ end }}
{{ if not .Lastmod.IsZero }}< meta property = "article:modified_time" content = "{{ .Lastmod.Format " 2006-01-02T15:04:05-07:00 " | safeHTML } } " > {{ end }}
{{ else }}
{{ if not .Date.IsZero }}
< meta property = "og:updated_time" content = "{{ .Date.Format " 2006-01-02T15:04:05-07:00 " | safeHTML } } " / >
{{ end }}
{{ end }}
{{ partial "jsonld/main" (dict "page" . "summary" $desc) }}
< title > {{$title}}< / title >
2023-10-26 19:24:58 +01:00
{{/* Load font theme */}}
{{ $font_family := "Inter var" }}
2024-05-06 23:14:37 +01:00
{{ $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}}
2023-10-26 19:24:58 +01:00
{{ $font := resources.Get (printf "dist/font/%s" $font_file) }}
< style >
@font-face {
font-family: '{{$font_family}}';
font-style: normal;
font-weight: 100 900;
font-display: swap;
2024-05-06 23:14:37 +01:00
src: url({{ $font.RelPermalink }}) format({{$font_type}});
2023-10-26 19:24:58 +01:00
}
< / style >
2023-10-29 09:18:33 +00:00
{{ 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 }}
< style >
#page-bg {
background-image: url('{{$bg_img.Permalink}}');
background-position: center;
background-size: cover;
}
< / style >
{{ else }}
{{ errorf "Couldn't find page background `%s` in the `assets/media/` folder - please add it." .Params.design.background.image.filename }}
{{ end }}
{{ end }}
2023-10-27 20:56:53 +01:00
{{/* Init prior to auto-chunking/bundling scripts due to Hugo concurrency issues */}}
2024-05-05 22:44:12 +01:00
{{/* !CACHED! Initialized once at site level and then cached for each page */}}
2023-10-27 20:56:53 +01:00
{{- partialCached "init.html" . -}}
2023-10-27 20:29:18 +01:00
{{/* Load Third-Party Libraries */}}
{{ partial "libraries.html" . }}
2023-11-07 23:09:38 +00:00
{{ $js_license := printf "/*! Hugo Blox Builder Tailwind UI v%s | https://hugoblox.com/ */\n" site.Data.hugoblox.version }}
2023-10-27 20:29:18 +01:00
{{ $js_license := $js_license | printf "%s/*! Copyright 2016-present George Cushen (https://georgecushen.com/) */\n" }}
2023-11-07 23:09:38 +00:00
{{ $js_license := $js_license | printf "%s/*! License: https://github.com/HugoBlox/hugo-blox-builder/blob/main/LICENSE.md */\n" }}
2023-10-27 20:29:18 +01:00
{{ $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 }}
2023-12-29 23:34:33 +00:00
{{ $js_academic := resources.Get "js/hb-code-copy.js" | js.Build (dict "targetPath" (printf "js/wow-core-%s.js" .Lang ) "params" $js_params) }}
2023-10-27 20:29:18 +01:00
{{ $js_academic := $js_academic | resources.Minify }}
2023-12-29 23:34:33 +00:00
{{- $js_theme := resources.Get "js/hb-theme.js" | resources.Minify -}}
2023-12-02 22:30:48 +00:00
{{- $js_lang := resources.Get "js/hb-i18n.js" | resources.Minify -}}
2023-12-14 23:55:19 +00:00
{{- $js_nav := resources.Get "js/hb-nav.js" | resources.Minify -}}
2024-02-17 21:29:09 +00:00
{{- $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) }}
2023-10-27 20:29:18 +01:00
{{- if hugo.IsProduction -}}
2023-10-27 20:40:09 +01:00
{{ $js_bundle = $js_bundle | fingerprint "sha256" }}
2023-10-27 20:29:18 +01:00
{{- end -}}
< script
defer
src="{{ $js_bundle.RelPermalink }}"
integrity="{{ $js_bundle.Data.Integrity }}"
>< / script >
2023-10-24 18:31:41 +01:00
{{/* EXTENSIBILITY HOOK: HEAD-END */}}
{{ partial "functions/get_hook" (dict "hook" "head-end" "context" .) }}
< / head >