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>
This commit is contained in:
Matheus Flausino
2026-01-29 18:06:12 -03:00
committed by GitHub
parent 50b9c927c2
commit 744e843880
5 changed files with 41 additions and 6 deletions

View File

@@ -505,6 +505,15 @@ outputs:
- خلاصه صفحات و تاریخ انتشار - خلاصه صفحات و تاریخ انتشار
- لینک‌های مستقیم به تمام محتوا - لینک‌های مستقیم به تمام محتوا
می‌توانید صفحات یا بخش‌های خاصی را با تنظیم `llms: false` در frontmatter آنها حذف کنید:
```yaml
---
title: "یادداشت‌های داخلی"
llms: false
---
```
فایل llms.txt به طور خودکار از ساختار محتوای شما ایجاد می‌شود و سایت شما را برای ابزارهای هوش مصنوعی و مدل‌های زبانی برای زمینه و مرجع قابل دسترس‌تر می‌کند. فایل llms.txt به طور خودکار از ساختار محتوای شما ایجاد می‌شود و سایت شما را برای ابزارهای هوش مصنوعی و مدل‌های زبانی برای زمینه و مرجع قابل دسترس‌تر می‌کند.
### Open Graph ### Open Graph

View File

@@ -505,6 +505,15 @@ outputs:
- ページの要約と公開日 - ページの要約と公開日
- すべてのコンテンツへの直接リンク - すべてのコンテンツへの直接リンク
フロントマターで `llms: false` を設定することで、特定のページやセクションを除外できます:
```yaml
---
title: "内部メモ"
llms: false
---
```
llms.txt ファイルはコンテンツ構造から自動生成され、AI ツールや言語モデルがコンテキストや参照のためにあなたのサイトにアクセスしやすくします。 llms.txt ファイルはコンテンツ構造から自動生成され、AI ツールや言語モデルがコンテキストや参照のためにあなたのサイトにアクセスしやすくします。
### Open Graph ### Open Graph

View File

@@ -600,6 +600,15 @@ This will generate an `llms.txt` file at your site's root containing:
- Page summaries and publication dates - Page summaries and publication dates
- Direct links to all content - Direct links to all content
You can exclude specific pages or sections by setting `llms: false` in their front matter:
```yaml
---
title: "Internal Notes"
llms: false
---
```
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. 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.
### Open Graph ### Open Graph

View File

@@ -505,6 +505,15 @@ outputs:
- 页面摘要和发布日期 - 页面摘要和发布日期
- 所有内容的直接链接 - 所有内容的直接链接
您可以通过在 front matter 中设置 `llms: false` 来排除特定页面或章节:
```yaml
---
title: "内部笔记"
llms: false
---
```
llms.txt 文件根据内容结构自动生成,使 AI 工具和语言模型更容易获取上下文和参考。 llms.txt 文件根据内容结构自动生成,使 AI 工具和语言模型更容易获取上下文和参考。
### Open Graph ### Open Graph

View File

@@ -1,14 +1,13 @@
# {{ .Site.Title }} # {{ .Site.Title }}
> {{ .Site.Params.description }} > {{ .Site.Params.description | default "" }}
{{ range $section := site.Sections }} {{ range where site.Sections "Params.llms" "ne" false }}
{{- template "llms-section-tree" dict "context" . "level" 2 }} {{- template "llms-section-tree" dict "context" . "level" 2 }}
{{ end }} {{ end }}
{{- $rootPages := where site.RegularPages "Section" "" }} {{- $rootPages := where (where site.RegularPages "Section" "") "Params.llms" "ne" false }}
{{- if $rootPages }} {{- if $rootPages }}
## Root Pages ## Root Pages
{{- range $rootPages }} {{- range $rootPages }}
- [{{ .Title }}]({{ .Permalink }}): {{ .Summary | plainify | truncate 100 | strings.TrimSpace }}{{ if .Date }} - Published {{ .Date.Format "2006-01-02" }}{{ end }} - [{{ .Title }}]({{ .Permalink }}): {{ .Summary | plainify | truncate 100 | strings.TrimSpace }}{{ if .Date }} - Published {{ .Date.Format "2006-01-02" }}{{ end }}
@@ -26,11 +25,11 @@ Site: {{ .Site.BaseURL }}
{{- "\n" -}} {{- "\n" -}}
{{ $headerHashes }} {{ $context.Title }} {{ $headerHashes }} {{ $context.Title }}
{{- range $context.RegularPages }} {{- range where $context.RegularPages "Params.llms" "ne" false }}
- [{{ .Title }}]({{ .Permalink }}): {{ .Summary | plainify | truncate 100 | strings.TrimSpace }}{{ if .Date }} - Published {{ .Date.Format "2006-01-02" }}{{ end }} - [{{ .Title }}]({{ .Permalink }}): {{ .Summary | plainify | truncate 100 | strings.TrimSpace }}{{ if .Date }} - Published {{ .Date.Format "2006-01-02" }}{{ end }}
{{- end }} {{- end }}
{{- range $context.Sections }} {{- range where $context.Sections "Params.llms" "ne" false }}
{{ template "llms-section-tree" dict "context" . "level" (add $level 1) }} {{ template "llms-section-tree" dict "context" . "level" (add $level 1) }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}