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

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

Remix には2つの方法があります。public/ に設定不要の静的ファイルを置く方法と、app/routes/llms[.]txt.ts にリソースルートを作成してプレーンテキストの Response を返す方法です。後者では、必要に応じてコンテンツから生成できます。

最終更新: 2026年4月22日

このページの内容

- [ オプション 1：public/ 内の静的ファイル ](#static)
- [ 選択肢2：リソースルート ](#resource-route)
- [ Viteプラグインによるアプローチ ](#vite-plugin)
- [ 検証 ](#verify)              
注記

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

以下の  静的ファイル  もしあなたの  llms.txt  の変更頻度が低く、コンテンツから生成する必要がない場合に使用します。
リソースルート  
を使った動的生成が適しています。特に、ドキュメントをデータベースに保存している場合や、MDXファイルから生成している場合に有効です。

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

Remixは `public/` サイトのルートディレクトリに静的に配置してください。 ファイルを以下の場所に配置してください
`public/llms.txt`、ルーティング設定は不要です。
public/llms.txt, directory structure    コピー     

```
# Remix static file approach
#
# Place your file at: public/llms.txt
# Remix (and the underlying Node/Cloudflare/Vercel adapter)
# serves everything in public/ at the root of your site.
#
# Project structure:
# your-remix-app/
# ├── public/
# │   └── llms.txt   ← add this
# ├── app/
# └── remix.config.js (or vite.config.ts)

```

この方法はすべての Remix アダプターで動作します: **@remix-run/node**, **@remix-run/cloudflare**, **@remix-run/vercel**、および **@remix-run/netlify**。静的ファイルは、一致するルートより優先されます。

## 選択肢2：リソースルート

リソースルートを作成する: `app/routes/llms[.]txt.ts`。 `[.]` 構文はファイル名のドットをエスケープするため、RemixはそれをURLパス `/llms.txt`。 `loader` 正しい Content-Type を持つ Response を返す関数。 `Response` 正しい
`Content-Type`.
app/routes/llms[.]txt.ts    コピー     

```
// app/routes/llms[.]txt.ts
// Remix resource route, the [.] escapes the dot in the filename
// This file is served at exactly /llms.txt
import type { LoaderFunctionArgs } from '@remix-run/node';

export async function loader({ request }: LoaderFunctionArgs) {
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.
- [API Reference](https://yoursite.com/docs/api): Full endpoint catalog.

## Product

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

## Optional

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

return new Response(content, {
status: 200,
headers: {
'Content-Type': 'text/plain; charset=utf-8',
'Cache-Control': 'public, max-age=3600, stale-while-revalidate=86400',
},
});
}

```

例

json() ではなく Web Response を使用してください

Remixの  json()  ヘルパーは  Content-Type: application/json . について  llms.txt  では必ず  new Response(body, { headers: { 'Content-Type': 'text/plain; charset=utf-8' }
})  
を直接返します。

コンテンツ層から動的に生成するには、loaderでドキュメントを取得し、Markdownのリンク一覧をプログラムで構築します:
app/routes/llms[.]txt.ts, dynamic    コピー     

```
// app/routes/llms[.]txt.ts
// Generate from your content / MDX files
import type { LoaderFunctionArgs } from '@remix-run/node';
import { getAllDocs } from '~/models/docs.server';

export async function loader({ request }: LoaderFunctionArgs) {
// Fetch your documentation index from a DB or file system
const docs = await getAllDocs();

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

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

return new Response(body, {
headers: {
'Content-Type': 'text/plain; charset=utf-8',
'Cache-Control': 'public, max-age=3600, stale-while-revalidate=86400',
},
});
}

```

## Viteプラグインによるアプローチ

RemixでVite（Remix v2.7+のデフォルト）を使う場合、 `llms.txt` を Vite プラグインでビルドの一部として生成できます。生成されたファイルは ビルド出力ディレクトリに配置され、静的アセットとして提供されます。これにより、静的ファイルの簡便さと
ビルド時のコンテンツアクセスを両立できます。
vite.config.ts, generate llms.txt at build    コピー     

```
import { vitePlugin as remix } from '@remix-run/dev';
import { defineConfig } from 'vite';
import { writeFileSync } from 'node:fs';
import { resolve } from 'node:path';

// Simple Vite plugin to generate llms.txt at build time
function llmsTxtPlugin() {
return {
name: 'generate-llms-txt',
buildStart() {
const content = `# Your Site\n\n> Summary.\n\n## Documentation\n\n- [Docs](https://yoursite.com/docs): Guide.\n`;
writeFileSync(resolve(__dirname, 'public/llms.txt'), content, 'utf-8');
},
};
}

export default defineConfig({
plugins: [remix(), llmsTxtPlugin()],
});
```

## 検証

デプロイ後、ファイルが正しく配信されていることを確認します:
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
```

## 関連ガイド

- [llms.txtの作成方法](/ja/how-to-create/)、テンプレート、チェックリスト。 
- [llms.txt フォーマットリファレンス](/ja/llms-txt-format/)、仕様の詳細。 
- [Vercelガイド](/ja/llms-txt-vercel/)、Remix を Vercel にデプロイします。 
- [Cloudflare Pages ガイド](/ja/llms-txt-cloudflare/), CloudflareでのRemix。 
- [バリデータ](/ja/validator/) · [ジェネレーター](/ja/generator/).        
## ソース

- [ llmstxt.org、コミュニティによる提案 ](https://llmstxt.org/)
- [ Remix ドキュメント、リソースルート ](https://v2.remix.run/docs/guides/resource-routes/)
- [ Remixドキュメント、ファイル規約 ](https://v2.remix.run/docs/file-conventions/routes/)
