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

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

Nuxt.jsには三つの方法がある：public/に静的ファイルを置く（設定不要）、動的生成用のNitroサーバールートを使う、またはNuxt Contentドキュメントから自動生成する。

最終更新: 2026年4月22日

このページの内容

- [ オプション 1：public/ 内の静的ファイル ](#static)
- [ 選択肢2：サーバーAPIルート ](#server-route)
- [ オプション3：Nuxt Contentで自動生成 ](#nuxt-content)
- [ Nitroおよびデプロイ先 ](#nitro)
- [ 検証 ](#verify)              
注記

どの方法を使うべきですか？

以下の  静的ファイル  もしあなたの  llms.txt  ほとんど変わらないなら  サーバールート  コンテンツからリクエスト時またはビルド時に生成したい場合に使用します。使用するのは  Nuxt Content連携  （Markdownファイルでドキュメントを管理している場合）。

## オプション 1：public/ 内の静的ファイル

Nuxtは `public/` ディレクトリをビルド出力に直接配置し、 サイトのルートで配信します。ファイルを `public/llms.txt` そして `/llms.txt` デプロイ先ごとに利用できます。
public/llms.txt, directory structure    コピー     

```
# Nuxt static file approach
#
# Place your file at: public/llms.txt
# Nuxt copies everything in public/ directly to the build output.
#
# Project structure:
# your-nuxt-app/
# ├── public/
# │   └── llms.txt   ← add this
# ├── pages/
# └── nuxt.config.ts
#
# No configuration needed. Works with all deployment presets.

```

この方法は設定不要で、すべての Nitro プリセットで同じように動作します: **node-server**, **cloudflare-pages**, **vercel**, **netlify**、および **static**.

## 選択肢2：サーバー API ルート

以下の場所にファイルを作成してください： `server/routes/llms.txt.ts`。Nuxt の Nitro
エンジンはファイルを `server/routes/` URLパスに直接対応するため、このファイルは正確に `/llms.txt` 追加の ルーティング設定なしで提供されます。
server/routes/llms.txt.ts    コピー     

```
// server/routes/llms.txt.ts
// Nuxt server route, served at /llms.txt
export default defineEventHandler(() => {
const content = `# Your Site

> One-sentence description of what your site or product does.

## Documentation

- [Getting Started](https://yoursite.com/docs/start): Install and configure in minutes.
- [API Reference](https://yoursite.com/docs/api): Full endpoint catalog with examples.

## Product

- [Overview](https://yoursite.com/product): Core features and capabilities.
- [Pricing](https://yoursite.com/pricing): Plans and billing details.

## Optional

- [Changelog](https://yoursite.com/changelog): Release history.
- [GitHub](https://github.com/your-org/your-repo): Source code.
`;

setResponseHeader(event, 'Content-Type', 'text/plain; charset=utf-8');
setResponseHeader(event, 'Cache-Control', 'public, max-age=3600, stale-while-revalidate=86400');
return content;
});

```

使用方法 `setResponseHeader` から `h3` ライブラリ（Nuxt に同梱）を使用して、正しい
`Content-Type`. 追加します `Cache-Control` ヘッダーを追加すると、CDN エッジがレスポンスをキャッシュし、オリジンの負荷を軽減できます。

## オプション3：Nuxt Contentで自動生成

次を使用する場合： [Nuxt Content](https://content.nuxt.com/) をドキュメントに使用している場合は、コンテンツコレクションを照会してリンク一覧を自動構築できます。これにより、
`llms.txt` 手動での更新を必要とせず、 ドキュメントと常に同期が保たれます。
server/routes/llms.txt.ts, Nuxt Content    コピー     

```
// server/routes/llms.txt.ts
// Auto-generate llms.txt from Nuxt Content documents
import { serverQueryContent } from '#content/server';

export default defineEventHandler(async (event) => {
// Query all docs; adjust collection name as needed
const docs = await serverQueryContent(event, '/docs')
.only(['title', 'description', '_path'])
.find();

const links = docs
.map((doc) => `- [${doc.title}](https://yoursite.com${doc._path}/): ${doc.description ?? ''}`)
.join('\n');

const body = [
'# Your Site',
'',
'> One-sentence description of your project.',
'',
'## Documentation',
'',
links,
].join('\n');

setResponseHeader(event, 'Content-Type', 'text/plain; charset=utf-8');
return body;
});

```

クエリパス（`/docs`）とフィールド名をコンテンツ構造に合わせて調整してください。デプロイ後に [バリデーター](/ja/validator/) デプロイ後に、書式設定の退行がないかを確認する。

## Nitroおよびデプロイ先

- **node-server**では、サーバールートが Node.js HTTP
ハンドラーとして実行されます。次の対象にリバースプロキシ（nginx/Caddy）のキャッシュルールを追加してください：
`/llms.txt` により、リクエストのたびにNodeへ到達するのを避けます。 
- **cloudflare-pages**、 `public/` は Cloudflare の グローバル CDN から配信されます。サーバーのルートは
Pages Functions になります。詳しくは [Cloudflare ガイド](/ja/llms-txt-cloudflare/) のキャッシュヘッダーについて確認してください。 
- **vercel**では、静的ファイルは自動的にエッジキャッシュされます。サーバールートは設定に応じてVercel
Serverless FunctionsまたはEdge Functionsになります。 
- **static** （完全に事前レンダリングされる場合）は、 `public/` 
では静的ファイル方式を使用します。完全な静的出力ではサーバールートを利用できません。   
## 検証

デプロイ後、ファイルが正しく配信されていることを確認します:
Verification    コピー     

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

curl https://yoursite.com/llms.txt | head -5
# Should print the first lines of your file
```

## 関連ガイド

- [llms.txtの作成方法](/ja/how-to-create/)、テンプレート、チェックリスト。 
- [llms.txt フォーマットリファレンス](/ja/llms-txt-format/)、仕様の詳細。 
- [Vercelガイド](/ja/llms-txt-vercel/)、デプロイとキャッシュヘッダー。 
- [Cloudflare Pages ガイド](/ja/llms-txt-cloudflare/)、CDN 設定。 
- [バリデータ](/ja/validator/) · [ジェネレーター](/ja/generator/).        
## ソース

- [ llmstxt.org、コミュニティによる提案 ](https://llmstxt.org/)
- [ Nuxt ドキュメント、サーバールート ](https://nuxt.com/docs/guide/directory-structure/server)
- [ Nuxt Contentドキュメント ](https://content.nuxt.com/)
