Skip to content

Commit 77645c2

Browse files
committed
site: add pagefind metadata for improved search ranking
Index description, keywords, and breadcrumbs as Pagefind metadata to improve search result relevance. Configure ranking weights to prioritize title matches and reduce term frequency bias. - Add pagefind-meta.html partial for centralized metadata - Move breadcrumb metadata from breadcrumbs.html to new partial - Configure metaWeights: title (10x), keywords (6x), description (4x) Assisted-By: cagent
1 parent f929b8f commit 77645c2

4 files changed

Lines changed: 18 additions & 8 deletions

File tree

layouts/_default/baseof.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
{{ if ne .Params.sitemap false }}data-pagefind-body{{- end }}
6464
class="dark:bg-background-dark w-full min-w-0 bg-white p-8"
6565
>
66+
{{ partial "pagefind-meta.html" . }}
6667
{{ block "main" . }}
6768
{{ end }}
6869
</div>

layouts/partials/breadcrumbs.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
<nav
22
id="breadcrumbs"
3-
{{- $breadcrumbTitles := slice }}
43
data-pagefind-ignore
54
class="breadcrumbs mb-4 flex min-w-0 items-center gap-2 text-gray-400 dark:text-gray-300"
65
>
76
{{ range .Ancestors.Reverse }}
8-
{{ $breadcrumbTitles = $breadcrumbTitles | append .LinkTitle }}
97
<a href="{{ .Permalink }}" class="link truncate"
108
>{{ markdownify .LinkTitle }}</a
119
>
1210
<span>/</span>
1311
{{- end }}
14-
<span
15-
data-pagefind-meta="breadcrumbs:{{ collections.Delimit $breadcrumbTitles " / " }}"
16-
class="truncate"
17-
>{{ markdownify .LinkTitle }}</span
18-
>
12+
<span class="truncate">{{ markdownify .LinkTitle }}</span>
1913
</nav>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{/* Pagefind metadata - must be inside data-pagefind-body */}}
2+
{{- $description := partial "utils/description.html" . -}}
3+
{{- $keywords := partialCached "utils/keywords.html" . . -}}
4+
{{- $breadcrumbs := slice -}}
5+
{{- range .Ancestors.Reverse -}}
6+
{{- $breadcrumbs = $breadcrumbs | append .LinkTitle -}}
7+
{{- end -}}
8+
{{- with $description }}<meta data-pagefind-meta="description:{{ . }}">{{ end }}
9+
{{- with $keywords }}<meta data-pagefind-meta="keywords:{{ delimit . ", " }}">{{ end }}
10+
{{- with $breadcrumbs }}<meta data-pagefind-meta="breadcrumbs:{{ delimit . " / " }}">{{ end }}

layouts/partials/search-bar.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
termFrequency: 0.0,
2424
termSimilarity: 2.0,
2525
pageLength: 0.0,
26-
termSaturation: 1.0
26+
termSaturation: 1.0,
27+
metaWeights: {
28+
title: 10.0,
29+
description: 4.0,
30+
keywords: 6.0
31+
}
2732
}
2833
});
2934

0 commit comments

Comments
 (0)