refactor: standardize all Hugo templates — consistent landmark structure

All templates now follow: body > nav > article > header + content + footer

Removed:
- <hgroup> (redundant, header+h1+p serves same purpose)
- <main> (article is the content landmark)
- role="main" on article (incorrect ARIA)
- header block in baseof (header now inside article)

Standardized: default, docs, essay, notes, console, page, list, index.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ludo 2026-04-11 18:37:47 +02:00
parent 080acfebb7
commit 21524b4b25
Signed by: ludo
GPG key ID: F6E479DEFAB84D6E
10 changed files with 156 additions and 258 deletions

View file

@ -5,10 +5,9 @@
</head> </head>
<body> <body>
{{ partial "nav.html" . }} {{ partial "nav.html" . }}
{{ block "header" . }}{{ end }}
{{ block "content" . }}{{ end }} {{ block "content" . }}{{ end }}
<footer> <footer>
<small><a href="/">{{ .Site.Title }}</a> · {{ now.Format "2006" }}</small> <a href="/">{{ .Site.Title }}</a> · {{ now.Format "2006" }}
</footer> </footer>
</body> </body>
</html> </html>

View file

@ -1,24 +1,26 @@
{{ define "header" }}
<header>
<h1>{{ .Title }}</h1>
{{ with .Description }}<p>{{ . }}</p>{{ end }}
</header>
{{ end }}
{{ define "content" }} {{ define "content" }}
<article role="main"> <article>
<section> <header>
{{ range .Pages }} <h1>{{ .Title }}</h1>
<article> {{- with .Description }}
<header> <p>{{ . }}</p>
<h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2> {{- end }}
<p data-text="dim"> </header>
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2006" }}</time>
</p> {{ .Content }}
</header>
{{ with .Summary }}<p>{{ . }}</p>{{ end }} {{ range .Pages }}
</article> <article>
{{ end }} <header>
</section> <h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
{{- if not .Date.IsZero }}
<p data-text="dim">
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2006" }}</time>
</p>
{{- end }}
</header>
{{- with .Description }}<p>{{ . }}</p>{{ end }}
</article>
{{ end }}
</article> </article>
{{ end }} {{ end }}

View file

@ -1,23 +1,39 @@
{{ define "header" }}
<header>
{{ with .Type }}<p data-text="eyebrow">{{ . }}</p>{{ end }}
<p data-text="dim">
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2006" }}</time>
{{ with .Params.author }} · {{ . }}{{ end }}
</p>
{{ with .Params.tags }}
<p>{{ range . }}<a href="/tags/{{ . }}" data-text="tag">#{{ . }}</a> {{ end }}</p>
{{ end }}
</header>
{{ end }}
{{ define "content" }} {{ define "content" }}
<article role="main"> <article>
<header>
<h1>{{ .Title }}</h1>
{{- with .Description }}
<p>{{ . }}</p>
{{- end }}
{{- if or (not .Date.IsZero) .Params.author }}
<p data-text="dim">
{{- if not .Date.IsZero -}}
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2, 2006" }}</time>
{{- end -}}
{{- if and (not .Date.IsZero) .Params.author }} · {{ end -}}
{{- with .Params.author }}{{ . }}{{ end -}}
</p>
{{- end }}
{{- with .GetTerms "tags" }}
<nav aria-label="Tags">
{{- range . }}
<a href="{{ .Permalink }}">#{{ .Name }}</a>
{{- end }}
</nav>
{{- end }}
</header>
{{ .Content }} {{ .Content }}
{{ with .Params.footer }}
{{- if or .PrevInSection .NextInSection }}
<footer> <footer>
<small>{{ . }}</small> {{- with .PrevInSection }}
<a href="{{ .RelPermalink }}" rel="prev"><span aria-hidden="true"></span> {{ .LinkTitle }}</a>
{{- end }}
{{- with .NextInSection }}
<a href="{{ .RelPermalink }}" rel="next">{{ .LinkTitle }} <span aria-hidden="true"></span></a>
{{- end }}
</footer> </footer>
{{ end }} {{- end }}
</article> </article>
{{ end }} {{ end }}

View file

@ -1,87 +1,37 @@
{{ define "header" }}
<header>
{{- if .Description -}}
<hgroup>
<h1>{{ .Title }}</h1>
<p>{{ .Description }}</p>
</hgroup>
{{- else -}}
<h1>{{ .Title }}</h1>
{{- end }}
</header>
{{ end }}
{{ define "content" }} {{ define "content" }}
<section data-layout="console"> <section data-layout="console">
<nav aria-label="Documentation" data-nav="sidebar"> <nav aria-label="Documentation" data-nav="sidebar">
{{- $menu := index .Site.Menus "docs" -}} {{- $top := .FirstSection -}}
{{- if $menu -}} {{- range $top.Sections.ByWeight -}}
{{- range $menu -}} <h3>{{ .Title }}</h3>
{{- if .HasChildren -}} <ul>
<h3>{{ .Name }}</h3> {{- range .RegularPages.ByWeight -}}
<ul> <li>
{{- range .Children -}} <a href="{{ .RelPermalink }}"
<li> {{- if eq .RelPermalink $.RelPermalink }} aria-current="page"{{ end -}}>
<a href="{{ .URL }}" {{- .LinkTitle -}}
{{- if eq (relURL .URL) $.RelPermalink }} aria-current="page"{{ end -}}> </a>
{{- .Name -}} </li>
</a>
</li>
{{- end -}}
</ul>
{{- else -}}
<ul>
<li>
<a href="{{ .URL }}"
{{- if eq (relURL .URL) $.RelPermalink }} aria-current="page"{{ end -}}>
{{- .Name -}}
</a>
</li>
</ul>
{{- end -}}
{{- end -}}
{{- else -}}
{{- with .CurrentSection -}}
<h3>{{ .Title }}</h3>
<ul>
{{- range .RegularPages -}}
<li>
<a href="{{ .RelPermalink }}"
{{- if eq .RelPermalink $.RelPermalink }} aria-current="page"{{ end -}}>
{{- .LinkTitle -}}
</a>
</li>
{{- end -}}
</ul>
{{- end -}} {{- end -}}
</ul>
{{- end -}} {{- end -}}
</nav> </nav>
<article> <article>
{{ .Content }} <header>
<h1>{{ .Title }}</h1>
{{- with .Description }}
<p>{{ . }}</p>
{{- end }}
</header>
{{- if or .PrevInSection .NextInSection -}} {{ .Content }}
<footer data-role="prev-next">
{{- with .NextInSection -}}
<a href="{{ .RelPermalink }}" rel="prev">
<span aria-hidden="true"></span> Previous
<span>{{ .LinkTitle }}</span>
</a>
{{- end -}}
{{- with .PrevInSection -}}
<a href="{{ .RelPermalink }}" rel="next">
Next <span aria-hidden="true"></span>
<span>{{ .LinkTitle }}</span>
</a>
{{- end -}}
</footer>
{{- end -}}
</article> </article>
{{- with .TableOfContents -}} {{- with .TableOfContents -}}
<aside data-toc> <aside data-toc>
<h3>On this page</h3> <h3>{{ i18n "onThisPage" | default "On this page" }}</h3>
{{ . }} {{ . }}
</aside> </aside>
{{- end -}} {{- end -}}

View file

@ -1,16 +1,3 @@
{{ define "header" }}
<header>
{{- if .Description -}}
<hgroup>
<h1>{{ .Title }}</h1>
<p>{{ .Description }}</p>
</hgroup>
{{- else -}}
<h1>{{ .Title }}</h1>
{{- end }}
</header>
{{ end }}
{{ define "content" }} {{ define "content" }}
<section data-layout="docs"> <section data-layout="docs">
@ -32,20 +19,25 @@
</nav> </nav>
<article> <article>
<header>
<h1>{{ .Title }}</h1>
{{- with .Description }}
<p>{{ . }}</p>
{{- end }}
</header>
{{ .Content }} {{ .Content }}
{{- if or .PrevInSection .NextInSection -}} {{- if or .PrevInSection .NextInSection -}}
<footer data-role="prev-next"> <footer>
{{- with .NextInSection -}} {{- with .NextInSection -}}
<a href="{{ .RelPermalink }}" rel="prev"> <a href="{{ .RelPermalink }}" rel="prev">
<span aria-hidden="true"></span> Previous <span aria-hidden="true"></span> {{ .LinkTitle }}
<span>{{ .LinkTitle }}</span>
</a> </a>
{{- end -}} {{- end -}}
{{- with .PrevInSection -}} {{- with .PrevInSection -}}
<a href="{{ .RelPermalink }}" rel="next"> <a href="{{ .RelPermalink }}" rel="next">
Next <span aria-hidden="true"></span> {{ .LinkTitle }} <span aria-hidden="true"></span>
<span>{{ .LinkTitle }}</span>
</a> </a>
{{- end -}} {{- end -}}
</footer> </footer>

View file

@ -1,38 +1,38 @@
{{ define "header" }}
<header>
<h1>{{ .Title }}</h1>
{{ with .Description }}<p data-abstract>{{ . }}</p>{{ end }}
{{- $hasDate := not .Date.IsZero -}}
{{- $hasAuthor := .Params.author -}}
{{- if or $hasDate $hasAuthor -}}
<p data-byline>
{{- if $hasDate -}}
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2, 2006" }}</time>
{{- end -}}
{{- if and $hasDate $hasAuthor }} · {{ end -}}
{{- with .Params.author }}{{ . }}{{ end -}}
</p>
{{- end }}
{{- with .GetTerms "tags" }}
<nav data-role="tag-cloud" aria-label="Tags">
{{- range . }}
<a href="{{ .Permalink }}" data-tag="{{ .Name }}">{{ .Name }}</a>
{{- end }}
</nav>
{{- end }}
</header>
{{ end }}
{{ define "content" }} {{ define "content" }}
<article role="main"> <article data-paper>
<header>
{{- with .Params.eyebrow }}<p data-text="eyebrow">{{ . }}</p>{{ end }}
<h1>{{ .Title }}</h1>
{{- with .Params.abstract }}
<p data-abstract>{{ . }}</p>
{{- end }}
{{- if or (not .Date.IsZero) .Params.author }}
<p data-byline>
{{- if not .Date.IsZero -}}
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2, 2006" }}</time>
{{- end -}}
{{- if and (not .Date.IsZero) .Params.author }} · {{ end -}}
{{- with .Params.author }}{{ . }}{{ end -}}
</p>
{{- end }}
{{- with .GetTerms "tags" }}
<nav data-role="tag-cloud" aria-label="Tags">
{{- range . }}
<a href="{{ .Permalink }}">{{ .Name }}</a>
{{- end }}
</nav>
{{- end }}
</header>
{{ .Content }} {{ .Content }}
{{- if or .PrevInSection .NextInSection }} {{- if or .PrevInSection .NextInSection }}
<footer> <footer>
{{- with .PrevInSection }} {{- with .PrevInSection }}
<a href="{{ .RelPermalink }}" rel="prev">← {{ .LinkTitle }}</a> <a href="{{ .RelPermalink }}" rel="prev"><span aria-hidden="true"></span> {{ .LinkTitle }}</a>
{{- end }} {{- end }}
{{- with .NextInSection }} {{- with .NextInSection }}
<a href="{{ .RelPermalink }}" rel="next">{{ .LinkTitle }} →</a> <a href="{{ .RelPermalink }}" rel="next">{{ .LinkTitle }} <span aria-hidden="true"></span></a>
{{- end }} {{- end }}
</footer> </footer>
{{- end }} {{- end }}

View file

@ -1,28 +1,26 @@
{{ define "title" }}{{ .Site.Title }}{{ end }} {{ define "content" }}
<article>
{{ define "header" }} <header>
<header>
<hgroup>
<h1>{{ .Site.Title }}</h1> <h1>{{ .Site.Title }}</h1>
<p>{{ .Site.Params.description | default "An agent-first approach to web generation." }}</p> <p>{{ .Site.Params.description | default "An agent-first approach to web generation." }}</p>
</hgroup> </header>
</header>
{{ end }} {{ .Content }}
{{ define "content" }}
<article role="main">
<section> <section>
<h2>Recent</h2> <h2>Recent</h2>
{{ range first 10 .Site.RegularPages }} {{ range first 10 .Site.RegularPages }}
<article> <article>
<header> <header>
<h3><a href="{{ .Permalink }}">{{ .Title }}</a></h3> <h3><a href="{{ .Permalink }}">{{ .Title }}</a></h3>
{{- if not .Date.IsZero }}
<p data-text="dim"> <p data-text="dim">
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2006" }}</time> <time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2006" }}</time>
{{ with .Params.eyebrow }} · {{ . }}{{ end }} {{- with .Params.eyebrow }} · {{ . }}{{ end }}
</p> </p>
{{- end }}
</header> </header>
{{ with .Summary }}<p>{{ . }}</p>{{ end }} {{- with .Description }}<p>{{ . }}</p>{{ end }}
</article> </article>
{{ end }} {{ end }}
</section> </section>

View file

@ -1,14 +1,11 @@
{{ define "header" }}
<header>
<hgroup>
<h1>{{ .Title }}</h1>
{{ with .Description }}<p>{{ . }}</p>{{ end }}
</hgroup>
</header>
{{ end }}
{{ define "content" }} {{ define "content" }}
<main> <article>
<header>
<h1>{{ .Title }}</h1>
{{- with .Description }}
<p>{{ . }}</p>
{{- end }}
</header>
{{ .Content }} {{ .Content }}
</main> </article>
{{ end }} {{ end }}

View file

@ -1,87 +1,31 @@
{{ define "header" }}
<header>
{{- if .Description -}}
<hgroup>
<h1>{{ .Title }}</h1>
<p>{{ .Description }}</p>
</hgroup>
{{- else -}}
<h1>{{ .Title }}</h1>
{{- end }}
</header>
{{ end }}
{{ define "content" }} {{ define "content" }}
<section data-layout="docs"> <section data-layout="docs">
<nav aria-label="Notes" data-nav="sidebar"> <nav aria-label="Notes" data-nav="sidebar">
{{- $menuName := .Site.Params.notes_menu | default "notes" -}} {{- with .CurrentSection -}}
{{- $menu := index .Site.Menus $menuName -}} <h3>{{ .Title }}</h3>
{{- if $menu -}} <ul>
{{- range $menu -}} {{- range .RegularPages.ByWeight -}}
{{- if .HasChildren -}} <li>
<h3>{{ .Name }}</h3> <a href="{{ .RelPermalink }}"
<ul> {{- if eq .RelPermalink $.RelPermalink }} aria-current="page"{{ end -}}>
{{- range .Children -}} {{- .LinkTitle -}}
<li> </a>
<a href="{{ .URL }}" </li>
{{- if $.IsMenuCurrent $menuName . }} aria-current="page"{{ end -}}>
{{- .Name -}}
</a>
</li>
{{- end -}}
</ul>
{{- else -}}
<ul>
<li>
<a href="{{ .URL }}"
{{- if $.IsMenuCurrent $menuName . }} aria-current="page"{{ end -}}>
{{- .Name -}}
</a>
</li>
</ul>
{{- end -}}
{{- end -}}
{{- else -}}
{{- with .CurrentSection -}}
<h3>{{ .Title }}</h3>
<ul>
{{- range .RegularPages -}}
<li>
<a href="{{ .RelPermalink }}"
{{- if eq .RelPermalink $.RelPermalink }} aria-current="page"{{ end -}}>
{{- .LinkTitle -}}
</a>
</li>
{{- end -}}
</ul>
{{- end -}} {{- end -}}
</ul>
{{- end -}} {{- end -}}
</nav> </nav>
<article> <article>
{{ .Content }} <header>
<h1>{{ .Title }}</h1>
{{- with .Description }}
<p>{{ . }}</p>
{{- end }}
</header>
{{- $prevURL := index .Params "prev-url" -}} {{ .Content }}
{{- $prevTitle := index .Params "prev-title" -}}
{{- $nextURL := index .Params "next-url" -}}
{{- $nextTitle := index .Params "next-title" -}}
{{- if or $prevURL $nextURL -}}
<footer data-role="prev-next">
{{- if $prevURL -}}
<a href="{{ $prevURL }}" rel="prev">
<span aria-hidden="true"></span> Previous
<span>{{ $prevTitle }}</span>
</a>
{{- end -}}
{{- if and $nextURL $nextTitle -}}
<a href="{{ $nextURL }}" rel="next">
Next <span aria-hidden="true"></span>
<span>{{ $nextTitle }}</span>
</a>
{{- end -}}
</footer>
{{- end -}}
</article> </article>
{{- with .TableOfContents -}} {{- with .TableOfContents -}}

View file

@ -1,11 +1,11 @@
{{ define "header" }}{{ end }}
{{ define "content" }} {{ define "content" }}
<main> <article>
<header> <header>
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
{{- with .Description }}<p>{{ . }}</p>{{ end }} {{- with .Description }}
<p>{{ . }}</p>
{{- end }}
</header> </header>
{{ .Content }} {{ .Content }}
</main> </article>
{{ end }} {{ end }}