theme: better HTML titles and breadcrumbs for search and tag pages #521

This commit is contained in:
Sören Weber 2023-05-04 22:07:59 +02:00
parent b11969b3d0
commit 98c88d8e2e
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -10,11 +10,15 @@
{{- partial "meta.html" . }} {{- partial "meta.html" . }}
{{- $page := . }} {{- $page := . }}
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }} {{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}
{{- $title := "" }} {{- $title := .Title }}
{{- if and .Title (not (eq .Title .Site.Title)) }} {{- if eq $outputFormat "searchpage" }}
{{- $title = printf "%s %s " .Title (default "::" .Site.Params.titleSeparator) }} {{- $title = T "Search" }}
{{- else if eq .Kind "term" }}
{{- $title = printf "%s %s" (.Data.Singular | humanize) $title }}
{{- end }}
{{- if and $title (not (eq $title .Site.Title)) }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }}
{{- end }} {{- end }}
{{- $title = printf "%s%s" $title .Site.Title }}
<title>{{ $title }}</title> <title>{{ $title }}</title>
{{- if .IsTranslated -}} {{- if .IsTranslated -}}
@ -173,7 +177,14 @@
{{- $remaining = sub $remaining 1 }} {{- $remaining = sub $remaining 1 }}
{{- if $ispublished }} {{- if $ispublished }}
{{- $depth = add $depth 1 }} {{- $depth = add $depth 1 }}
<li itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement">{{ if $remaining }}<a itemprop="item" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{end}}<span itemprop="name">{{ if $to.Title }}{{ $to.Title }}{{ else }}{{ $to.Site.Title }}{{ end }}</span>{{ if $remaining }}</a>{{ end }}<meta itemprop="position" content="{{ $depth }}">{{ if $remaining }} > {{ end }}</li> {{- $title := $to.Title }}
{{- if eq .Kind "term" }}
{{- $title = printf "%s %s" (.Data.Singular | humanize) $title }}
{{- end }}
{{- if not $title }}
{{- $title = $to.Site.Title }}
{{- end }}
<li itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement">{{ if $remaining }}<a itemprop="item" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{end}}<span itemprop="name">{{ $title }}</span>{{ if $remaining }}</a>{{ end }}<meta itemprop="position" content="{{ $depth }}">{{ if $remaining }} > {{ end }}</li>
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}