はじめに
近年、AI(ChatGPTなどの大規模言語モデル=LLM)は、
Web上のコンテンツを学習・要約・引用する際に、
構造化されたサイト情報 を参照します。
そのため、これまでの「SEO」だけでなく、
AIクローラ(LLM)に最適化されたメタ情報 の設置が重要になっています。
本記事では、個人サイトやWordPressブログでも簡単に導入できる
「llms.txt」「llms.jsonl」「robots.txt」を作成し、
AIにも検索エンジンにも優しい構成を実現する手順を紹介します。
前提条件
○独自ドメインのWebサイト(例:https://yourdomain.com/)
○FTP / WinSCP / SSH などでサーバーにアクセス可能
○UTF-8 形式のテキストファイルを扱えるエディタ(例:VS Code)
○WordPressを使っている場合は、自動生成される wp-sitemap.xml が有効
llms.txt の作成方法
基本構造
# llms.txt for yourdomain.com
# Owner: yourname
# Description: Structured Markdown index for AI & SEO crawlers
# Format: Markdown, UTF-8
## 投稿
### [記事タイトル1](https://yourdomain.com/post-1/)
カテゴリー: 技術
公開日: 2025-10-01
更新日: 2025-10-03
概要: 本文の概要を一文。
## 固定ページ
### [ホーム](https://yourdomain.com/home/)
カテゴリー: 固定ページ
公開日: 2025-08-01
更新日: 2025-09-01
概要: サイトトップページの紹介。
ポイント
Markdown形式で統一(AI・検索エンジンの両方が解析可能)
UTF-8(BOMなし)で保存
ファイル名は llms.txt
サーバーのルートに配置 → https://yourdomain.com/llms.txt
パーミッション設定
chmod 644 llms.txt
llms.jsonl の作成方法
JSON Lines形式(1行=1記事)
下記は例です。
{“title”: “記事タイトル1”, “url”: “https://yourdomain.com/post-1/”, “category”: “技術”, “published”: “2025-10-01”, “modified”: “2025-10-03”, “excerpt”: “本文の概要を一文。”, “type”: “post”}
{“title”: “ホーム”, “url”: “https://yourdomain.com/home/”, “category”: “固定ページ”, “published”: “2025-08-01”, “modified”: “2025-09-01”, “excerpt”: “サイトトップページの紹介。”, “type”: “page”}
仕様
○UTF-8(BOMなし、もしくはUTF-8 with BOMでも可)
○ファイル名:llms.jsonl
○1行ごとに記事を定義(機械学習用に最適)
パーミッション設定
chmod 644 llms.jsonl
robots.txt の設定
AIや検索エンジンに llms.txt / llms.jsonl を発見させるために robots.txt に以下を追記します。
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
# AI・検索エンジン向けファイルを許可
Allow: /llms.txt
Allow: /llms.jsonl
# サイトマップを指定
Sitemap: https://yourdomain.com/wp-sitemap.xml
動作確認
ブラウザで以下を開きます
https://yourdomain.com/llms.txt
https://yourdomain.com/llms.jsonl
それぞれ正しく内容が表示されればOK。
Google Search Console にサイトマップを登録
https://yourdomain.com/wp-sitemap.xml
Bing Webmaster Tools にも同様に登録可能
AIクローラの検出
OpenAIの GPTBot, Anthropicの ClaudeBot, Perplexity, Google-Extended などのAIクローラは自動的にこれらファイルを検出します。
ファイル構成のまとめ
| ファイル名 | 目的 | 主な読者 |
|---|---|---|
llms.txt |
人間+AI向けの簡易インデックス | AIクローラ、検索エンジン |
llms.jsonl |
機械読み取り専用インデックス | LLM、AI検索 |
robots.txt |
クロール許可+案内 | すべてのクローラ |
wp-sitemap.xml |
投稿・固定ページ一覧 | 検索エンジン(Google/Bing) |
上級編:自動更新の仕組み
WordPress REST APIやPythonスクリプトを使えば、llms.jsonl を自動的に生成・更新することもできます。
まとめ
○llms.txt → AIが読みやすい「見える」構造化リスト
○llms.jsonl → AIが解析しやすい「データ」形式
○robots.txt → それらを案内する地図
この3点を設置すれば、あなたのサイトは AI・検索エンジン・ユーザーすべてにフレンドリー な構造になります。
推奨ファイル構成
/public_html/
├── llms.txt
├── llms.jsonl
├── robots.txt
└── wp-sitemap.xml(WordPressが自動生成)
※UTF-8(BOMなし、もしくはUTF-8 with BOMでも可)使用にするのを忘れると文字化けします。
※上記をしっかりしても文字化けする時は、.htaccess ファイルで UTF-8 を許可していないかもしれません。
※私は上記の切り分けに苦労しました。
2025/11/20(木)追記:
上記まで読んで下さった中には、結局どうやってこれらを書くのか、悩まれた方も多いと思います。
すみません。方法を書くのを忘れました。ごめんなさい。
やりたいこと
https://yourdomain.com/llms.txt
https://yourdomain.com/llms.jsonl
にアクセスしたときに、WordPress が 自動生成して返すようにする(物理ファイルを手で更新しなくてよい)。
コードを書く場所(どれか1つ)
子テーマの functions.php に追記
私は
yourdomain.com/wp-content/themes/cocoon-child-master/function.php
に追記して、再度、アップロードしました。
もしくは「Code Snippets」プラグインで
新規スニペット → PHP → サイト全体で有効化
親テーマ直書きは更新で消えるので、子テーマ or Code Snippets 推奨です。
① llms.txt / llms.jsonl を出すスニペット(コピペOK)
下のコードを そのまま貼って ください。(yourdomai.com、yourname の書き換えを忘れずに。)
(タイトル:LLMS endpoints など)
<?php //子テーマ用関数
if ( !defined( 'ABSPATH' ) ) exit;
//子テーマ用のビジュアルエディタースタイルを適用
add_editor_style();
//以下に子テーマ用の関数を書く
/**
* llms.txt / llms.jsonl を自動生成して返す
*/
// 1) リライトルール追加: /llms.txt /llms.jsonl を認識させる
add_action( 'init', function() {
add_rewrite_rule( '^llms\.txt$', 'index.php?llms_format=txt', 'top' );
add_rewrite_rule( '^llms\.jsonl$', 'index.php?llms_format=jsonl', 'top' );
});
// 2) クエリ変数を追加
add_filter( 'query_vars', function( $vars ) {
$vars[] = 'llms_format';
return $vars;
});
// 3) 出力本体
add_action( 'template_redirect', function() {
$format = get_query_var( 'llms_format' );
if ( ! $format ) {
return; // 通常のページ表示
}
// 投稿・固定ページを取得(必要に応じて調整)
$args = array(
'post_type' => array( 'post', 'page' ),
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC',
);
$query = new WP_Query( $args );
// 共通で使うデータ整形
$items = array();
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$post_id = get_the_ID();
$title = get_the_title();
$url = get_permalink();
$excerpt = get_the_excerpt();
$date = get_the_date( 'Y-m-d' );
$modified = get_the_modified_date( 'Y-m-d' );
$cats = get_the_category();
$cat_names = array();
if ( $cats ) {
foreach ( $cats as $cat ) {
$cat_names[] = $cat->name;
}
}
$items[] = array(
'title' => $title,
'url' => $url,
'excerpt' => $excerpt,
'categories' => $cat_names,
'published' => $date,
'modified' => $modified,
'post_type' => get_post_type( $post_id ),
);
}
wp_reset_postdata();
}
// --- llms.jsonl 出力 ---
if ( $format === 'jsonl' ) {
header( 'Content-Type: application/json; charset=utf-8' );
foreach ( $items as $item ) {
// liacsy.com の llms.jsonl と揃えたい場合は、
// ここでキー名を調整してください
$line = array(
'url' => $item['url'],
'title' => $item['title'],
'description' => $item['excerpt'],
'categories' => $item['categories'],
'published' => $item['published'],
'modified' => $item['modified'],
'type' => $item['post_type'],
);
echo wp_json_encode( $line, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ) . "\n";
}
exit;
}
// --- llms.txt 出力(Markdown 形式)---
if ( $format === 'txt' ) {
header( 'Content-Type: text/plain; charset=utf-8' );
echo "# llms.txt for Prompt4LLM (https://yourdomain.com/)\n";
echo "# Owner: yourname\n";
echo "# Description: Generated from llms.jsonl (Structured index for AI & SEO crawlers)\n";
echo "# Last Updated: " . date_i18n( 'Y-m-d' ) . "\n";
echo "# Format: Markdown, UTF-8\n\n";
//「投稿」と「固定ページ」を分ける例
echo "## 投稿\n\n";
foreach ( $items as $item ) {
if ( $item['post_type'] !== 'post' ) {
continue;
}
$cat_str = ! empty( $item['categories'] ) ? implode( ', ', $item['categories'] ) : '未分類';
echo "### [{$item['title']}]({$item['url']})\n";
echo "- カテゴリー: {$cat_str}\n";
echo "- 公開日: {$item['published']}\n";
echo "- 更新日: {$item['modified']}\n";
echo "- URL: {$item['url']}\n";
echo "- 概要: {$item['excerpt']}\n\n";
}
echo "## 固定ページ\n\n";
foreach ( $items as $item ) {
if ( $item['post_type'] !== 'page' ) {
continue;
}
echo "### [{$item['title']}]({$item['url']})\n";
echo "- 公開日: {$item['published']}\n";
echo "- 更新日: {$item['modified']}\n";
echo "- URL: {$item['url']}\n";
echo "- 概要: {$item['excerpt']}\n\n";
}
exit;
}
});
※最初の行の 「<?php」は要らないと思います。私は入れてしまい、エラーになりました。
② 設置後にやること(重要)
スニペット/functions.php を保存・有効化
WordPress 管理画面 → 設定 → パーマリンク
→ 何も変えずに「変更を保存」をクリック
→ これでリライトルールが再生成されます
ブラウザで確認
https://yourdomain.com/llms.jsonl
https://yourdomain.com/llms.txt
中身が出ていれば成功です。
中身が出ていればと言いましたが、物理的にディレクトリにファイルは存在しません。
アクセスした瞬間、最新反映された llms.jsonl / llms.txt が生成されます。
以上です。
Views: 52

