Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/content/docs/guide/configuration.fa.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,11 @@ params:
```diff {filename="hugo.yaml"}
outputs:
- home: [html]
- page: [html]
- section: [html, rss]
+ home: [html, llms]
page: [html]
section: [html, rss]
+ page: [html, markdown]
+ section: [html, markdown, rss]
```

این کار یک فایل `llms.txt` در ریشه سایت شما ایجاد می‌کند که شامل:
Expand Down
8 changes: 5 additions & 3 deletions docs/content/docs/guide/configuration.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,19 @@ params:
```diff {filename="hugo.yaml"}
outputs:
- home: [html]
- page: [html]
- section: [html, rss]
+ home: [html, llms]
page: [html]
section: [html, rss]
+ page: [html, markdown]
+ section: [html, markdown, rss]
```

これにより、サイトのルートに `llms.txt` ファイルが生成され、以下が含まれます:

- サイトタイトルと説明
- すべてのセクションとページの階層リスト
- ページの要約と公開日
- すべてのコンテンツへの直接リンク
- すべてのコンテンツへの直接リンク(Markdown形式)

llms.txt ファイルはコンテンツ構造から自動生成され、AI ツールや言語モデルがコンテキストや参照のためにあなたのサイトにアクセスしやすくします。

Expand Down
8 changes: 5 additions & 3 deletions docs/content/docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,17 +455,19 @@ To enable [llms.txt](https://llmstxt.org/) output format for your site, which pr
```diff {filename="hugo.yaml"}
outputs:
- home: [html]
- page: [html]
- section: [html, rss]
+ home: [html, llms]
page: [html]
section: [html, rss]
+ page: [html, markdown]
+ section: [html, markdown, rss]
```

This will generate an `llms.txt` file at your site's root containing:

- Site title and description
- Hierarchical listing of all sections and pages
- Page summaries and publication dates
- Direct links to all content
- Direct links to all content in markdown format

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.

Expand Down
8 changes: 5 additions & 3 deletions docs/content/docs/guide/configuration.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,19 @@ params:
```diff {filename="hugo.yaml"}
outputs:
- home: [html]
- page: [html]
- section: [html, rss]
+ home: [html, llms]
page: [html]
section: [html, rss]
+ page: [html, markdown]
+ section: [html, markdown, rss]
```

这将在站点根目录生成一个 `llms.txt` 文件,包含:

- 站点标题和描述
- 所有章节和页面的层次结构列表
- 页面摘要和发布日期
- 所有内容的直接链接
- 所有内容的直接链接(Markdown格式)

llms.txt 文件根据内容结构自动生成,使 AI 工具和语言模型更容易获取上下文和参考。

Expand Down
4 changes: 2 additions & 2 deletions docs/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ hasCJKLanguage: true

outputs:
home: [html, llms]
page: [html]
section: [html, rss]
page: [html, markdown]
section: [html, markdown, rss]

defaultContentLanguage: en
languages:
Expand Down
3 changes: 3 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
baseName = 'llms'
mediaType = 'text/plain'
isPlainText = true
[outputFormats.markdown]
name = 'Markdown'
baseName = 'index.html'
2 changes: 2 additions & 0 deletions layouts/list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# {{ .Title }}
{{ .RawContent | htmlUnescape }}
71 changes: 48 additions & 23 deletions layouts/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,60 @@

> {{ .Site.Params.description }}

{{ range $section := site.Sections }}
{{- template "llms-section-tree" dict "context" . "level" 2 }}
{{ end }}

{{- $rootPages := where site.RegularPages "Section" "" }}
{{- if $rootPages }}
{{- if and (not .Params.llmstxt.optional) (gt (len .Pages) 0) }}
{{- range .Site.Sections }}
{{- if and (not .Params.llmstxt.optional) (not .Params.llmstxt.exclude) }}
{{- $allSections := slice . -}}
{{- range .Sections -}}
{{- if and (not .Params.llmstxt.optional) (not .Params.llmstxt.exclude) -}}
{{- $allSections = $allSections | append . -}}
{{- end -}}
{{- end -}}
{{- range $allSections }}

## Root Pages
{{- range $rootPages }}
- [{{ .Title }}]({{ .Permalink }}): {{ .Summary | plainify | truncate 100 | strings.TrimSpace }}{{ if .Date }} - Published {{ .Date.Format "2006-01-02" }}{{ end }}
## {{ .Title }}
{{- range .Pages }}
{{- if not .Params.llmstxt.exclude }}
- [{{ .Title }}]({{ .Permalink }}index.html.md): {{ .Summary | plainify | truncate 100 | strings.TrimSpace }}{{ if .Date }} - Published {{ .Date.Format "2006-01-02" }}{{ end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

---
Generated on {{ now.Format "2006-01-02 15:04:05 UTC" }}
Site: {{ .Site.BaseURL }}
{{- $optionalPages := slice }}
{{- range .Site.Sections }}
{{- if and .Params.llmstxt.optional (not .Params.llmstxt.exclude) }}
{{- range .Pages }}
{{- if not .Params.llmstxt.exclude }}
{{- $optionalPages = $optionalPages | append . }}
{{- end }}
{{- end }}
{{- end }}
{{- range .Sections }}
{{- if and .Params.llmstxt.optional (not .Params.llmstxt.exclude) }}
{{- range .Pages }}
{{- if not .Params.llmstxt.exclude }}
{{- $optionalPages = $optionalPages | append . }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

{{- define "llms-section-tree" -}}
{{- $context := .context -}}
{{- $level := .level | default 2 -}}
{{- $headerHashes := strings.Repeat $level "#" -}}
{{- "\n" -}}
{{ $headerHashes }} {{ $context.Title }}
{{- if gt (len $optionalPages) 0 }}

{{- range $context.RegularPages }}
- [{{ .Title }}]({{ .Permalink }}): {{ .Summary | plainify | truncate 100 | strings.TrimSpace }}{{ if .Date }} - Published {{ .Date.Format "2006-01-02" }}{{ end }}
## Optional
{{- range $optionalPages }}
- [{{ .Title }}]({{ .Permalink }}index.html.md){{ with .Description }}: {{ . }}{{ else }}{{ with .Summary }}: {{ . | plainify | truncate 100 | strings.TrimSpace }}{{ end }}{{ end }}
{{- end }}

{{- range $context.Sections }}
{{ template "llms-section-tree" dict "context" . "level" (add $level 1) }}
{{- end }}
{{- else -}}
{{- .RawContent | .Page.RenderString -}}
{{- end -}}
{{- "\n" -}}
{{- "\n" -}}

---
Generated on {{ now.Format "2006-01-02 15:04:05 UTC" }}
Site: {{ .Site.BaseURL }}
2 changes: 2 additions & 0 deletions layouts/single.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# {{ .Title }}
{{ .RawContent | htmlUnescape }}