Port head partials: SEO, OG, JSON-LD, AI disclosure, tag-nav

- layouts/partials/head.html: full <head> partial with meta partials + CSS pipeline
- layouts/partials/meta/seo.html: canonical URL + robots directives
- layouts/partials/meta/og.html: Open Graph + Twitter Card meta tags
- layouts/partials/meta/ai-disclosure.html: AI content disclosure (EU AI Act)
- layouts/partials/meta/json-ld.html: Schema.org JSON-LD structured data
- layouts/partials/tag-nav.html: site-wide tag cloud partial
- layouts/_default/baseof.html: simplified to use partial head.html
- layouts/_default/single.html: removed inline head block (now in head.html)

Verified: canonical, robots, OG tags, ai-content-disclosure on live pages.
96 pages build clean.

Closes: asw#15
This commit is contained in:
Vigilio Desto 2026-04-10 18:42:21 +02:00
parent da1d02ccd1
commit 5deaa22e38
Signed by: vigilio
GPG key ID: 159D6AD58C8E55E9
8 changed files with 231 additions and 39 deletions

View file

@ -1,12 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ .Site.LanguageCode | default "en" }}"> <html lang="{{ .Site.LanguageCode | default "en" }}">
<head> <head>
<meta charset="utf-8"> {{- partial "head.html" . -}}
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ block "title" . }}{{ .Title }} — {{ .Site.Title }}{{ end }}</title>
{{ $css := resources.Get "css/asw-built.css" | minify | fingerprint }}
<link rel="stylesheet" href="{{ $css.RelPermalink }}">
{{ block "head" . }}{{ end }}
</head> </head>
<body> <body>
{{ block "main" . }}{{ end }} {{ block "main" . }}{{ end }}

View file

@ -1,36 +1,3 @@
{{ define "head" }}
<meta name="description" content="{{ .Description | default .Summary }}">
<meta name="color-scheme" content="dark light">
<meta name="ai-disclosure" content="{{ index .Params "ai-disclosure" | default "ai-assisted" }}">
<meta name="ai-model" content="{{ index .Params "ai-model" | default .Site.Params.aiModel | default "claude-sonnet-4-5" }}">
<meta name="ai-provider" content="{{ index .Params "ai-provider" | default .Site.Params.aiProvider | default "Anthropic" }}">
<meta name="author" content="{{ .Params.author | default .Site.Params.author | default .Site.Title }}">
<meta property="og:title" content="{{ .Title }}">
<meta property="og:description" content="{{ .Description | default .Summary }}">
<meta property="og:type" content="article">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:site_name" content="{{ .Site.Title }}">
<link rel="canonical" href="{{ .Permalink }}">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "CreativeWork",
"name": "{{ .Title }}",
"author": {
"@type": "SoftwareApplication",
"name": "{{ .Site.Params.author | default .Site.Title }}",
"url": "{{ .Site.BaseURL }}"
},
"dateModified": "{{ .Lastmod.Format `2006-01-02` }}",
"generator": "Agentic Semantic Web"
}
</script>
{{ end }}
{{ define "main" }} {{ define "main" }}
{{ partial "nav.html" . }} {{ partial "nav.html" . }}

View file

@ -0,0 +1,26 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="dark light">
<title>
{{- if .IsHome -}}
{{ .Site.Title }}
{{- else -}}
{{ .Title }} · {{ .Site.Title }}
{{- end -}}
</title>
{{- with .Description }}<meta name="description" content="{{ . }}">{{- end }}
{{- if not .Description }}{{- with .Site.Params.description }}<meta name="description" content="{{ . }}">{{- end }}{{- end }}
{{- /* ── Meta partials ─────────────────────────────────────────── */}}
{{- partial "meta/seo.html" . -}}
{{- partial "meta/og.html" . -}}
{{- partial "meta/ai-disclosure.html" . -}}
{{- partial "meta/json-ld.html" . -}}
{{- /* ── CSS — fingerprinted via Hugo Pipes ─────────────────────── */}}
{{ $css := resources.Get "css/asw-built.css" | minify | fingerprint }}
<link rel="stylesheet" href="{{ $css.RelPermalink }}">
{{- range .AlternativeOutputFormats -}}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
{{- end }}

View file

@ -0,0 +1,25 @@
{{- /*
partials/meta/ai-disclosure.html — AI-generated content disclosure
Emits the proposed W3C/WHATWG AI content disclosure meta tag and the
corresponding HTTP-equiv header that satisfies EU AI Act Article 50
obligations for AI-generated/AI-assisted web content.
The disclosure level is controlled per-page via front matter:
ai_content: "generated" — fully AI-generated content
ai_content: "assisted" — human-written with AI assistance (default)
ai_content: "reviewed" — AI-generated, human-reviewed and edited
ai_content: "none" — no AI involvement (suppresses the tag)
Site-wide default in hugo.toml:
[params]
ai_content = "assisted" # default for all pages
Reference:
https://github.com/nickvdyck/ai-content-disclosure
EU AI Act Article 50 (transparency obligations, Chapter IV)
*/ -}}
{{- $level := or .Params.ai_content .Site.Params.ai_content "assisted" -}}
{{- if ne $level "none" -}}
<meta name="ai-content-disclosure" content="{{ $level }}">
{{- end }}

View file

@ -0,0 +1,101 @@
{{- /*
partials/meta/json-ld.html — JSON-LD structured data (Schema.org)
Emits one <script type="application/ld+json"> block per page.
Uses dict → jsonify → safeHTML to avoid Hugo's JS-context escaping.
Schema selection:
Home page → WebSite (with SearchAction if params.search_url set)
Docs pages → TechArticle (front matter: type = "docs")
Dated pages → Article
Everything else → WebPage
BreadcrumbList appended when .Ancestors is non-empty.
Configure in hugo.toml:
[params]
author = "Trentuna" # publisher/author name
logo = "/images/logo.png" # site logo for publisher
search_url = "/search/?q={q}" # enables SearchAction on WebSite
*/ -}}
{{- $author := or .Site.Params.author .Site.Title -}}
{{- $logo := .Site.Params.logo | default "" -}}
{{- $desc := or .Description .Site.Params.description "" -}}
{{- $image := or .Params.image .Site.Params.og_image "" -}}
{{- if .IsHome -}}
{{- /* ── WebSite ──────────────────────────────────────────────────── */}}
{{- $data := dict
"@context" "https://schema.org"
"@type" "WebSite"
"name" .Site.Title
"url" .Site.BaseURL
"description" $desc
-}}
{{- with .Site.Params.search_url -}}
{{- $action := dict
"@type" "SearchAction"
"target" (dict "@type" "EntryPoint" "urlTemplate" (printf "%s%s" $.Site.BaseURL .))
"query-input" "required name=q"
-}}
{{- $data = merge $data (dict "potentialAction" $action) -}}
{{- end -}}
{{- printf "<script type=\"application/ld+json\">%s</script>" ($data | jsonify) | safeHTML -}}
{{- else -}}
{{- /* ── Article / TechArticle / WebPage ─────────────────────────── */}}
{{- $schemaType := "WebPage" -}}
{{- if and .IsPage (not .IsSection) -}}
{{- if eq .Params.type "docs" -}}
{{- $schemaType = "TechArticle" -}}
{{- else if .Date -}}
{{- $schemaType = "Article" -}}
{{- end -}}
{{- end -}}
{{- $publisher := dict "@type" "Organization" "name" $author -}}
{{- with $logo -}}
{{- $publisher = merge $publisher (dict "logo" (dict "@type" "ImageObject" "url" (. | absURL))) -}}
{{- end -}}
{{- $data := dict
"@context" "https://schema.org"
"@type" $schemaType
"headline" .Title
"description" $desc
"url" .Permalink
"author" $publisher
"publisher" $publisher
-}}
{{- with $image -}}
{{- $data = merge $data (dict "image" (. | absURL)) -}}
{{- end -}}
{{- if and .Date (not .IsSection) -}}
{{- $data = merge $data (dict
"datePublished" (.Date.Format "2006-01-02T15:04:05Z07:00")
"dateModified" (.Lastmod.Format "2006-01-02T15:04:05Z07:00")
) -}}
{{- end -}}
{{- /* BreadcrumbList: .Ancestors is nearest→root; iterate by index to reverse */}}
{{- with .Ancestors -}}
{{- $ancs := . -}}
{{- $len := len $ancs -}}
{{- $items := slice -}}
{{- range $i := seq $len -}}
{{- $a := index $ancs (sub $len $i) -}}
{{- $item := dict "@type" "ListItem" "position" $i "name" $a.Title "item" $a.Permalink -}}
{{- $items = $items | append $item -}}
{{- end -}}
{{- $last := dict "@type" "ListItem" "position" (add $len 1) "name" $.Title "item" $.Permalink -}}
{{- $items = $items | append $last -}}
{{- $crumb := dict "@type" "BreadcrumbList" "itemListElement" $items -}}
{{- $data = merge $data (dict "breadcrumb" $crumb) -}}
{{- end -}}
{{- printf "<script type=\"application/ld+json\">%s</script>" ($data | jsonify) | safeHTML -}}
{{- end }}

View file

@ -0,0 +1,41 @@
{{- /*
partials/meta/og.html — Open Graph + Twitter Card meta tags
og:title Page title (site title for home page)
og:description .Description → .Site.Params.description → ""
og:url .Permalink
og:type "website" (home) | "article" (everything else)
og:site_name .Site.Title
og:image .Params.image → .Site.Params.og_image → absent
twitter:card "summary_large_image" when image present, else "summary"
twitter:site .Site.Params.twitter (optional @handle)
Configure in hugo.toml:
[params]
og_image = "/images/og-default.png" # fallback OG image
twitter = "@yourhandle" # omit if not on Twitter/X
*/ -}}
{{- $title := cond .IsHome .Site.Title (printf "%s · %s" .Title .Site.Title) -}}
{{- $desc := or .Description .Site.Params.description "" -}}
{{- $image := or .Params.image .Site.Params.og_image "" -}}
{{- $type := cond .IsHome "website" "article" -}}
<meta property="og:title" content="{{ $title }}">
<meta property="og:description" content="{{ $desc }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:type" content="{{ $type }}">
<meta property="og:site_name" content="{{ .Site.Title }}">
{{- with $image }}
<meta property="og:image" content="{{ . | absURL }}">
{{- end }}
{{- /* Twitter / X Card */}}
<meta name="twitter:card" content="{{ if $image }}summary_large_image{{ else }}summary{{ end }}">
<meta name="twitter:title" content="{{ $title }}">
<meta name="twitter:description" content="{{ $desc }}">
{{- with $image }}
<meta name="twitter:image" content="{{ . | absURL }}">
{{- end }}
{{- with .Site.Params.twitter }}
<meta name="twitter:site" content="{{ . }}">
{{- end }}

View file

@ -0,0 +1,16 @@
{{- /*
partials/meta/seo.html — canonical URL + robots directives
Outputs:
<link rel="canonical"> Always emitted; uses .Permalink (absolute).
<meta name="robots"> "noindex, nofollow" on draft/future pages,
"index, follow" otherwise.
No params required. Works from any page context.
*/ -}}
<link rel="canonical" href="{{ .Permalink }}">
{{- if or .Draft (gt .Date now) }}
<meta name="robots" content="noindex, nofollow">
{{- else }}
<meta name="robots" content="index, follow">
{{- end }}

View file

@ -0,0 +1,21 @@
{{- /*
tag-nav.html — renders all site tags as a navigable tag cloud.
Usage in a layout:
{{ partial "tag-nav.html" . }}
Outputs: <nav data-role="tag-cloud"> with links to each tag page.
The (N) count shows how many pages have each tag.
*/ -}}
{{- $tags := .Site.Taxonomies.tags -}}
{{- if $tags }}
<nav data-role="tag-cloud" aria-label="Browse by tag">
{{- range $name, $pages := $tags }}
{{- $tagPage := site.GetPage (printf "/tags/%s" ($name | urlize)) }}
<a href="{{ if $tagPage }}{{ $tagPage.Permalink }}{{ else }}{{ print site.BaseURL "tags/" ($name | urlize) "/" }}{{ end }}" data-tag="{{ $name }}">
{{ $name -}}
<small>({{ len $pages }})</small>
</a>
{{- end }}
</nav>
{{- end }}