<!-- Generated from ja/llms-txt-hugo/index.html. The canonical document is the HTML page. -->

- [ ホーム ](/ja/) 
/
- [ 作成方法 ](/ja/how-to-create/) 
/
- Hugoガイド            
# Hugo 向け `llms.txt`

二つの方法があります。static/ に静的ファイルを置く方法（設定不要でどこでも動作）と、ビルド時にコンテンツから llms.txt を自動生成するカスタム出力形式を使う方法です。

最終更新: 2026年4月22日

このページの内容

- [ オプション 1：静的ファイル（推奨） ](#static)
- [ 選択肢2：カスタム出力形式 ](#output-format)
- [ テンプレートの記述 ](#template)
- [ デプロイ ](#deployment)
- [ 検証 ](#verify)              
注記

どの方法を使うべきですか？
llms.txt  の内容が安定していて手動更新する場合は、
静的ファイル 、設定不要でリスクもありません。コンテンツと自動的に同期させるなら、すべての  hugo  ビルドでは、
カスタム出力形式 .

## オプション 1：静的ファイル（推奨）

Hugoは `static/` ディレクトリを直接 `public/` ビルド出力へコピーします。 `llms.txt`
に配置すれば、どのホスティングプラットフォームでも `/llms.txt` どのホスティングプラットフォームでも、Hugoの設定変更は
不要です。
static/llms.txt, directory structure    コピー     

```
# Hugo, zero-config static approach
#
# Place your file at: static/llms.txt
# Hugo copies everything in static/ directly to the public/ output directory.
# Your file will be served at /llms.txt on any host.
#
# Project structure:
# your-hugo-site/
# ├── static/
# │   └── llms.txt   ← add this
# ├── content/
# ├── layouts/
# └── hugo.toml
#
# No config changes needed. Run "hugo" and it appears in public/llms.txt.

```

実行後、 `hugo`、そこには `public/llms.txt`
ビルド出力にあります。 `public/` Cloudflare Pages、Vercel、GitHub Pages、またはその他の
静的ホストへ。

## 選択肢2：カスタム出力形式

Hugo の出力形式システムでは、Go
テンプレートを使ってコンテンツから任意のファイル形式を生成できます。新しい `LLMSTXT` 形式を設定で定義してからテンプレートを作成すると、Hugoが
`public/llms.txt`
毎回自動的に `hugo` 実行時に生成します。

### ステップ1：設定に出力形式を追加
hugo.toml    コピー     

```
# hugo.toml, define the llmstxt custom output format

[outputs]
home = ["HTML", "RSS", "LLMSTXT"]

[outputFormats.LLMSTXT]
mediaType = "text/plain"
baseName = "llms"
isPlainText = true
notAlternative = true

```

YAMLを使う場合も設定は同じです。
hugo.yaml    コピー     

```
# hugo.yaml, same config in YAML

outputs:
home:
- HTML
- RSS
- LLMSTXT

outputFormats:
LLMSTXT:
mediaType: text/plain
baseName: llms
isPlainText: true
notAlternative: true

```

主な設定は `mediaType = "text/plain"` （Hugoがプレーンテキストファイルを書き出すため）、
`baseName = "llms"` （生成されるもの:
`llms.txt`）、そして `notAlternative = true` （不要な ` ` HTML にあるタグ）。

## テンプレートの記述

次の場所にテンプレートを作成します: `layouts/index.llmstxt.txt`。Hugoは *ホーム* テンプレートをルートレベルの出力に使用します。通常のページをすべて列挙する簡単な例を示します：
layouts/index.llmstxt.txt, simple    コピー     

```
{{/* layouts/index.llmstxt.txt */}}
{{/* Hugo home template for the llmstxt output format */}}
# {{ .Site.Title }}

> {{ .Site.Params.description }}

{{ with .Site.Params.llmstxtContext }}{{ . }}

{{ end -}}
## Pages

{{ range .Site.RegularPages -}}
- [{{ .Title }}]({{ .Permalink }}): {{ with .Description }}{{ . }}{{ else }}{{ .Summary | plainify | truncate 120 }}{{ end }}
{{ end }}

```

複数のコンテンツセクション（ブログ、ドキュメント、チュートリアル）があるサイトでは、セクション別に整理します：
layouts/index.llmstxt.txt, by section    コピー     

```
{{/* layouts/index.llmstxt.txt, organized by section */}}
# {{ .Site.Title }}

> {{ .Site.Params.description }}

{{ range .Site.Sections -}}
## {{ .Title }}

{{ range .Pages -}}
- [{{ .Title }}]({{ .Permalink }}): {{ with .Description }}{{ . }}{{ else }}{{ .Summary | plainify | truncate 100 }}{{ end }}
{{ end }}
{{ end -}}

## Optional

- [Homepage]({{ .Site.BaseURL }}): site entry point.

```

例

descriptionフロントマターを使用する

Hugoの  .Summary  は各ページの最初の段落から自動抽出されるため、優れたllms.txt項目としては長すぎたり、一般的すぎたりすることがよくあります。
description  正確で手作業による概要を作るため、フロントマターに
content/docs/getting-started.md    コピー     

```
---
# content/docs/getting-started.md
title: "Getting started"
description: "Install the CLI, run your first command, and deploy in under 5 minutes."
draft: false
---

Your content here...

```

## デプロイ

- **Cloudflare Pages**、ビルドコマンドを `hugo`
と公開ディレクトリを `public`。Cloudflare Pagesは
`public/llms.txt` に `/llms.txt` グローバル CDN から配信します。[Cloudflare
ガイド]を参照してください。 [Cloudflare Pages ガイド](/ja/llms-txt-cloudflare/) キャッシュヘッダーに関する推奨事項について。 
- **Vercel**,
Hugoは自動的に検出されます。ビルドコマンドを次のように設定してください： `hugo` および出力ディレクトリを
`public`。次を参照してください
[Vercelガイド](/ja/llms-txt-vercel/) のエッジキャッシュオプションについて確認してください。 
- **GitHub Pages**では、
`hugo` をデプロイします： `public/` を
`gh-pages` ブランチ。ファイルは次で配信されます：
`https://your-org.github.io/llms.txt`. 
- **任意の静的ホスト**, 展開する `public/` ディレクトリ。ファイルは ルートに配置され、正しく配信されます。   
## 検証

まずローカルで確認します。
Local verification    コピー     

```
hugo
ls public/llms.txt          # should exist
cat public/llms.txt          # check content
https_proxy="" hugo server
curl http://localhost:1313/llms.txt
```

デプロイ後：
Production verification    コピー     

```
curl -I https://yoursite.com/llms.txt
# Expected:
# HTTP/2 200
# content-type: text/plain; charset=utf-8
```

次に URL を [バリデーター](/ja/validator/) 完全な仕様準拠チェック用に

## 関連ガイド

- [llms.txtの作成方法](/ja/how-to-create/)、テンプレート、チェックリスト、およびすべてのスタック。 
- [Cloudflare Pages ガイド](/ja/llms-txt-cloudflare/), CF Pages に Hugo
をデプロイします。 
- [SvelteKit ガイド](/ja/llms-txt-sveltekit/)、別のSSGアプローチ。 
- [Astroガイド](/ja/llms-txt-astro/)、コンテンツ収集エンドポイント。 
- [ベストプラクティス](/ja/best-practices/)、何を含め、何を除外するか。 
- [バリデータ](/ja/validator/) · [ジェネレーター](/ja/generator/).        
## ソース

- [ llmstxt.org、コミュニティによる提案 ](https://llmstxt.org/)
- [ Hugo ドキュメント、カスタム出力形式 ](https://gohugo.io/configuration/output-formats/)
- [ Hugo ドキュメント、テンプレートの検索順 ](https://gohugo.io/templates/lookup-order/)
