Files
hugo-theme-stack/layouts/_partials/widget/taxonomy.html
T
230a28fa8d feat(widgets): link widget titles to their respective pages (#1277)
- archives.html: Link the "Archives" title to the archives page,
  consistent with how individual year links already work
- taxonomy.html: Change showLink default from false to true so
  tag-cloud and categories widget titles link to their taxonomy
  listing pages by default

Widget titles are the primary affordance users interact with, so
linking them to the full listing page improves navigation. The
showLink param can still be set to false to disable this.

Co-authored-by: delize <4028612+delize@users.noreply.github.com>
2026-03-05 13:18:32 +01:00

40 lines
1.1 KiB
HTML

{{- $context := .Context -}}
{{- if not .Params.taxonomy -}}
{{- warnf "Taxonomy field is required" -}}
{{- end -}}
{{- $taxonomy := index $context.Site.Taxonomies .Params.taxonomy -}}
{{- if not $taxonomy -}}
{{- warnf "Taxonomy %s not found" .Params.taxonomy -}}
{{- end -}}
{{- $taxonomyPage := $taxonomy.Page -}}
{{- $widgetTitle := .Params.title -}}
{{- $limit := default 10 .Params.limit -}}
{{- $icon := default .Params.taxonomy .Params.icon -}}
{{- $showLink := default true .Params.showLink -}}
<section class="widget tagCloud">
<div class="widget-icon">
{{ partial "helper/icon" $icon }}
</div>
<h2 class="widget-title section-title">
{{ if $showLink }}
<a href="{{ $taxonomyPage.RelPermalink }}">
{{ $widgetTitle }}
</a>
{{ else }}
{{ $widgetTitle }}
{{ end }}
</h2>
<div class="tagCloud-tags">
{{ range first $limit $taxonomy.ByCount }}
<a href="{{ .Page.RelPermalink }}">
{{ .Page.Title }}
</a>
{{ end }}
</div>
</section>