Hugoで生成したブログにllms.txtとllms-full.txtを導入した

Table of Contents

背景・動機

llms-full.txtで始めるAIサポートチャット - basemachina を読んだ。

最近gemini-cliで文章を書かせることが増えたので、自分の文章スタイルを学習させればブログを半自動生成できるんだろうなと思ったので試してみた。

試したこと・やったこと

1. llms.txtの規格について簡単に調査する

以下が仕様。 https://llmstxt.org/

  • llms.txt: サイトの概要や、サイトに含まれるページへのリンク一覧
  • llms-full.txt: サイト全体の情報を1つに収めた文書ファイル

各サービスのlls-full.txtは以下。

2. hugoに導入する

Hugo で作ったサイトに llms.txt と llms-full.txt を設置した を参考にした。

takeokunn/hugo-take-theme で次のlayoutを作成した。

index.llms.txt:

# takeokunn's blog

たけてぃ(@takeokunn)の個人的なメモです。

## URL Structure

Zettelkasten

- fleeting
    - 小さい技術的なメモ
- permanent
    - 纏まった技術的メモ
- poem
    - 個人的なポエム
- diary
    - 個人的な日記

## Content

{{ range .Site.RegularPages }}
- [{{ .Title }}]({{ .Permalink }})
{{ end }}

index.llmsfull.txt:

# {{ .Site.Title }}

> {{ .Site.Params.Description }}

{{/* Articles */}}
{{ range where (where (sort (.Site.GetPage "/posts/").Pages "Date" "desc") "Draft" "ne" true) "Sitemap.Disable" "ne" true }}
--------------------------------------------------------------------------------
title: "{{ .Title }}"
date: "{{ .Date.Format "2006-01-02" }}"
--------------------------------------------------------------------------------
{{ replaceRE "{{<\\s*comment\\s*>}}(.|\n)*?{{<\\s*/comment\\s*>}}" "" .RawContent -}}
{{ end -}}

{{/* Others */}}
{{ range slice "about.md" -}}
{{ with site.GetPage . -}}
--------------------------------------------------------------------------------
title: "{{ .Title }}"
lastmod: "{{ .Date.Format "2006-01-02" }}"
--------------------------------------------------------------------------------
{{ replaceRE "{{<\\s*comment\\s*>}}(.|\n)*?{{<\\s*/comment\\s*>}}" "" .RawContent -}}
{{ end -}}
{{ end -}}

takeokunn/bloghugo.toml を追記した。

[outputFormats]
[outputFormats.llms]
mediaType = "text/plain"
baseName = "llms"
isPlainText = true
rel = "alternate"
root = true

[outputFormats.llmsfull]
mediaType = "text/plain"
baseName = "llms-full"
isPlainText = true
rel = "alternate"
root = true

[outputs]
home = ["HTML", "llms", "llmsfull"]

得られた結果・所感

無事ホスティングできた。

今後の展開・検討事項

当初の予定とおり、llms-full.txtをgemini-cliに食わせて自分っぽい文章を生成させられるようにしたい。