Skip to content

Commit 744e843

Browse files
feat(llms): add option to exclude pages and sections from llms.txt (#918)
* feat: improve section filtering in llms.txt * fix(llms): correct where syntax and add page exclusion filter - Fix invalid Hugo template syntax in where clause - Use boolean comparison instead of string for llms param - Add filtering to recursive llms-section-tree template - Document llms exclusion feature in all languages (en, ja, fa, zh-cn) --------- Co-authored-by: Xin <xin@imfing.com>
1 parent 50b9c92 commit 744e843

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

docs/content/docs/guide/configuration.fa.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,15 @@ outputs:
505505
- خلاصه صفحات و تاریخ انتشار
506506
- لینک‌های مستقیم به تمام محتوا
507507

508+
می‌توانید صفحات یا بخش‌های خاصی را با تنظیم `llms: false` در frontmatter آنها حذف کنید:
509+
510+
```yaml
511+
---
512+
title: "یادداشت‌های داخلی"
513+
llms: false
514+
---
515+
```
516+
508517
فایل llms.txt به طور خودکار از ساختار محتوای شما ایجاد می‌شود و سایت شما را برای ابزارهای هوش مصنوعی و مدل‌های زبانی برای زمینه و مرجع قابل دسترس‌تر می‌کند.
509518

510519
### Open Graph

docs/content/docs/guide/configuration.ja.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,15 @@ outputs:
505505
- ページの要約と公開日
506506
- すべてのコンテンツへの直接リンク
507507

508+
フロントマターで `llms: false` を設定することで、特定のページやセクションを除外できます:
509+
510+
```yaml
511+
---
512+
title: "内部メモ"
513+
llms: false
514+
---
515+
```
516+
508517
llms.txt ファイルはコンテンツ構造から自動生成され、AI ツールや言語モデルがコンテキストや参照のためにあなたのサイトにアクセスしやすくします。
509518

510519
### Open Graph

docs/content/docs/guide/configuration.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,15 @@ This will generate an `llms.txt` file at your site's root containing:
600600
- Page summaries and publication dates
601601
- Direct links to all content
602602

603+
You can exclude specific pages or sections by setting `llms: false` in their front matter:
604+
605+
```yaml
606+
---
607+
title: "Internal Notes"
608+
llms: false
609+
---
610+
```
611+
603612
The llms.txt file is automatically generated from your content structure and makes your site more accessible to AI tools and language models for context and reference.
604613

605614
### Open Graph

docs/content/docs/guide/configuration.zh-cn.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,15 @@ outputs:
505505
- 页面摘要和发布日期
506506
- 所有内容的直接链接
507507

508+
您可以通过在 front matter 中设置 `llms: false` 来排除特定页面或章节:
509+
510+
```yaml
511+
---
512+
title: "内部笔记"
513+
llms: false
514+
---
515+
```
516+
508517
llms.txt 文件根据内容结构自动生成,使 AI 工具和语言模型更容易获取上下文和参考。
509518

510519
### Open Graph

layouts/llms.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# {{ .Site.Title }}
22

3-
> {{ .Site.Params.description }}
3+
> {{ .Site.Params.description | default "" }}
44

5-
{{ range $section := site.Sections }}
5+
{{ range where site.Sections "Params.llms" "ne" false }}
66
{{- template "llms-section-tree" dict "context" . "level" 2 }}
77
{{ end }}
88

9-
{{- $rootPages := where site.RegularPages "Section" "" }}
9+
{{- $rootPages := where (where site.RegularPages "Section" "") "Params.llms" "ne" false }}
1010
{{- if $rootPages }}
11-
1211
## Root Pages
1312
{{- range $rootPages }}
1413
- [{{ .Title }}]({{ .Permalink }}): {{ .Summary | plainify | truncate 100 | strings.TrimSpace }}{{ if .Date }} - Published {{ .Date.Format "2006-01-02" }}{{ end }}
@@ -26,11 +25,11 @@ Site: {{ .Site.BaseURL }}
2625
{{- "\n" -}}
2726
{{ $headerHashes }} {{ $context.Title }}
2827

29-
{{- range $context.RegularPages }}
28+
{{- range where $context.RegularPages "Params.llms" "ne" false }}
3029
- [{{ .Title }}]({{ .Permalink }}): {{ .Summary | plainify | truncate 100 | strings.TrimSpace }}{{ if .Date }} - Published {{ .Date.Format "2006-01-02" }}{{ end }}
3130
{{- end }}
3231

33-
{{- range $context.Sections }}
32+
{{- range where $context.Sections "Params.llms" "ne" false }}
3433
{{ template "llms-section-tree" dict "context" . "level" (add $level 1) }}
3534
{{- end }}
3635
{{- end -}}

0 commit comments

Comments
 (0)