diff --git a/layouts/partials/breadcrumb.html b/layouts/partials/breadcrumb.html
index 5b1042ed..f3852754 100644
--- a/layouts/partials/breadcrumb.html
+++ b/layouts/partials/breadcrumb.html
@@ -2,12 +2,12 @@
{{- range .Ancestors.Reverse }}
{{- if not .IsHome }}
{{- partial "utils/icon.html" (dict "name" "chevron-right" "attributes" "class=\"hx-w-3.5 hx-shrink-0 rtl:-hx-rotate-180\"") -}}
{{ end -}}
{{ end -}}
- {{- .LinkTitle -}}
+ {{- partial "utils/title" . -}}
diff --git a/layouts/partials/components/pager.html b/layouts/partials/components/pager.html
index cae58f5b..1849b208 100644
--- a/layouts/partials/components/pager.html
+++ b/layouts/partials/components/pager.html
@@ -28,22 +28,24 @@
{{- if or $prev $next -}}
{{- if $prev -}}
+ {{- $linkTitle := partial "utils/title" $prev -}}
{{- partial "utils/icon.html" (dict "name" "chevron-right" "attributes" "class=\"hx-inline hx-h-5 hx-shrink-0 ltr:hx-rotate-180\"") -}}
- {{- $prev.LinkTitle -}}
+ {{- $linkTitle -}}
{{- end -}}
{{- if $next -}}
+ {{- $linkTitle := partial "utils/title" $next -}}
- {{- $next.LinkTitle -}}
+ {{- $linkTitle -}}
{{- partial "utils/icon.html" (dict "name" "chevron-right" "attributes" "class=\"hx-inline hx-h-5 hx-shrink-0 rtl:-hx-rotate-180\"") -}}
{{- end -}}
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html
index 65e154c5..78ebf63a 100644
--- a/layouts/partials/sidebar.html
+++ b/layouts/partials/sidebar.html
@@ -78,13 +78,14 @@
{{- range $items.ByWeight }}
{{- if .Params.sidebar.separator -}}
- {{ .LinkTitle }}
+ {{ partial "utils/title" . }}
{{- else -}}
{{- $active := eq $pageURL .RelPermalink -}}
{{- $shouldOpen := or (.Params.sidebar.open) (.IsAncestor $page) $active | default true }}
- {{- template "sidebar-item-link" dict "context" . "active" $active "title" .LinkTitle "link" .RelPermalink -}}
+ {{- $linkTitle := partial "utils/title" . -}}
+ {{- template "sidebar-item-link" dict "context" . "active" $active "title" $linkTitle "link" .RelPermalink -}}
{{- if and $toc $active -}}
{{- template "sidebar-toc" dict "page" . -}}
{{- end -}}
@@ -98,9 +99,9 @@
{{- range $items.ByWeight }}
{{- $active := eq $pageURL .RelPermalink -}}
{{- $shouldOpen := or (.Params.sidebar.open) (.IsAncestor $page) $active | default true }}
- {{- $title := .LinkTitle | default .File.BaseFileName -}}
+ {{- $linkTitle := partial "utils/title" . -}}
- {{- template "sidebar-item-link" dict "context" . "active" $active "title" $title "link" .RelPermalink -}}
+ {{- template "sidebar-item-link" dict "context" . "active" $active "title" $linkTitle "link" .RelPermalink -}}
{{- if and $toc $active -}}
{{ template "sidebar-toc" dict "page" . }}
{{- end }}
diff --git a/layouts/partials/utils/title.html b/layouts/partials/utils/title.html
new file mode 100644
index 00000000..0ab0afae
--- /dev/null
+++ b/layouts/partials/utils/title.html
@@ -0,0 +1,19 @@
+{{/*
+ This utility is used to retrieve the title of a page or section.
+ If no title is set, it falls back to using the directory or file name.
+
+ Based on https://github.com/thegeeklab/hugo-geekdoc/blob/v0.44.0/layouts/partials/utils/title.html
+*/}}
+{{- $title := "" }}
+
+{{ if .LinkTitle }}
+ {{ $title = .LinkTitle }}
+{{ else if .Title }}
+ {{ $title = .Title }}
+{{ else if and .IsSection .File }}
+ {{ $title = path.Base .File.Dir | humanize | title }}
+{{ else if and .IsPage .File }}
+ {{ $title = .File.BaseFileName | humanize | title }}
+{{ end }}
+
+{{ return $title -}}