From 53d243fab37278ba823e93c337fe9850f49566ac Mon Sep 17 00:00:00 2001 From: Florian Hoss Date: Wed, 12 Nov 2025 18:17:58 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Exclude=20pages=20from=20search=20i?= =?UTF-8?q?ndex=20via=20param?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pages with the 'excludeFromSearch' parameter set in their front matter are now omitted from the generated search index. This allows for finer control over which pages are searchable. --- layouts/_default/index.json | 46 +++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/layouts/_default/index.json b/layouts/_default/index.json index b301c8d6..a7260a52 100644 --- a/layouts/_default/index.json +++ b/layouts/_default/index.json @@ -4,28 +4,30 @@ {{ $pages = $pages | lang.Merge .Site.Pages }} {{ end }} {{- range $pages -}} - {{- $section := .Site.GetPage "section" .Section -}} - {{- if .Date -}} - {{- $index = $index | append (dict - "date" (.Date | time.Format (.Site.Language.Params.dateFormat | default ":date_long")) - "title" (.Title | emojify | safeJS) - "section" ($section.Title | emojify | safeJS) - "summary" (.Summary | safeJS) - "content" (.Plain | safeJS) - "permalink" .RelPermalink - "externalUrl" .Params.externalUrl - "type" .Type - ) -}} - {{- else -}} - {{- $index = $index | append (dict - "title" (.Title | emojify | safeJS) - "section" ($section.Title | emojify | safeJS) - "summary" (.Summary | safeJS) - "content" (.Plain | safeJS) - "permalink" .RelPermalink - "externalUrl" .Params.externalUrl - "type" .Type - ) -}} + {{- if not .Params.excludeFromSearch -}} + {{- $section := .Site.GetPage "section" .Section -}} + {{- if .Date -}} + {{- $index = $index | append (dict + "date" (.Date | time.Format (.Site.Language.Params.dateFormat | default ":date_long")) + "title" (.Title | emojify | safeJS) + "section" ($section.Title | emojify | safeJS) + "summary" (.Summary | safeJS) + "content" (.Plain | safeJS) + "permalink" .RelPermalink + "externalUrl" .Params.externalUrl + "type" .Type + ) -}} + {{- else -}} + {{- $index = $index | append (dict + "title" (.Title | emojify | safeJS) + "section" ($section.Title | emojify | safeJS) + "summary" (.Summary | safeJS) + "content" (.Plain | safeJS) + "permalink" .RelPermalink + "externalUrl" .Params.externalUrl + "type" .Type + ) -}} + {{- end -}} {{- end -}} {{- end -}} {{- $index | jsonify -}} \ No newline at end of file