كيفية إنشاء ملف llms.txt
ثلاثة قوالب وقائمة فحص وتعليمات نشر قابلة للنسخ واللصق لكل حزمة تقنية شائعة.
آخر تحديث:
1. خطّط لما ستضمّنه
قبل كتابة أي شيء، اسرد من 5 إلى 20 صفحة على موقعك مما سيحتاج نموذج لغة كبير إلى معرفته للإجابة عن أسئلة حول مشروعك. فكّر فيه كقائمة قراءة منتقاة لا خريطة موقع.
حزم بداية مفيدة:
- المنتج، نظرة عامة وحالات الاستخدام والأسعار.
- التوثيق، والبدء، ومرجع API، والأدلة الأساسية.
- التكاملات, الشركاء وSDK، سطر لكل واحد.
- مرجع, وسجل التغييرات وصفحة الحالة وسياسة الأمن.
- اختياري, أصول العلامة التجارية والصحافة والأرشيف.
إذا لم تساعد الصفحة نموذج لغة كبيراً في الإجابة عن أسئلة مستخدمين حقيقية، فاتركها خارجاً. وأكبر خطأ بفارق واضح هو إدراج كل شيء، فهذا يخفف الإشارة.
2. قالب أدنى
عنوان H1 هو العنصر الإلزامي الوحيد. ويضيف القالب أدناه ملخصاً وروابط لجعل الملف مفيداً.
# {Site name}
> {One-sentence description of what your site is about.}
## Pages
- [{Page title}]({absolute URL}): {short note}
3. القالب الموصى به
بالنسبة إلى معظم المواقع، هذا القالب نقطة البداية المناسبة: ملخص اقتباس وفقرة سياق وثلاثة إلى أربعة أقسام.
# {Site name}
> {One- or two-sentence overview. Factual, no marketing claims.}
{Optional 1–3 sentences of context: what this site covers, who it's for, and how the file below is curated.}
## Product
- [Product overview]({URL}): high-level capabilities.
- [Pricing]({URL}): plans and limits.
## Documentation
- [Getting started]({URL}): install, first call, hello world.
- [API reference]({URL}): full endpoint catalog.
- [Guides]({URL}): tutorials and how-tos.
## Optional
- [Changelog]({URL}): version history.
- [Brand assets]({URL}): logos and color palette.
4. قالب متقدم
عادةً ما تريد منصة SaaS أو منصة للمطوّرين ذات حجم أكبر بنية أعمق مع Optional القسم. استخدمه
نقطة بداية ثم قلّصه بصرامة.
# Acme
> Acme is a hosted analytics platform for product teams. The pages below cover product, pricing, the API, and integration guides.
The map here is curated for assistants, it is not exhaustive. Use it to answer questions about product capabilities, pricing tiers, integrations, SDKs, and migration from other tools. For the full corpus, see /llms-full.txt.
## Product
- [Product overview](https://acme.example/product): high-level capabilities.
- [Use cases](https://acme.example/use-cases): scenarios for product, marketing, and support teams.
- [Changelog](https://acme.example/changelog): monthly product updates.
## Pricing
- [Pricing tiers](https://acme.example/pricing): plans, limits, overage rules.
- [Billing FAQ](https://acme.example/billing-faq): invoices, taxes, refunds.
## Developers
- [REST API reference](https://docs.acme.example/api): full endpoint catalog.
- [Webhooks](https://docs.acme.example/webhooks): events, signatures, retries.
- [SDK, JavaScript](https://docs.acme.example/sdk/js): install, init, track events.
- [SDK, Python](https://docs.acme.example/sdk/python): install, init, track events.
## Integrations
- [Segment](https://docs.acme.example/integrations/segment): two-way sync.
- [Snowflake](https://docs.acme.example/integrations/snowflake): nightly export.
- [HubSpot](https://docs.acme.example/integrations/hubspot): contacts and events.
## Optional
- [Brand assets](https://acme.example/brand): logos, color palette.
- [Press releases](https://acme.example/press): historical announcements.
- [Status page](https://status.acme.example): real-time service health.
5. تحقّق
الصق ملفك في المدقّق للتأكد من مطابقته المواصفة. ومن المشكلات الشائعة
التي يلتقطها: غياب H1، وصياغة رابط مشوهة (- [name](url))، وعناوين URL النسبية،
ومحتوى خارج قسم، وH1 ثانٍ بالخطأ، وملفات ضخمة.
6. انشر على مكدسك
Cloudflare Pages
# Cloudflare Pages
# Place llms.txt in the public/ root of your project. It will be served at /llms.txt.
# Verify after deploy:
curl -I https://your-domain.com/llms.txt
→ دليل Cloudflare Pages الكامل
Vercel
ضع llms.txt في public/ دليل. ويقدّمه Vercel كما هو في /llms.txt.
Netlify
النهج نفسه: ضع الملف في دليلك الثابت (public/
لـ Next.js أو Astro، static/ لـ SvelteKit وHugo). وتقدمه Netlify على /llms.txt.
Next.js
// Next.js (App Router), public/llms.txt is served as-is.
// 1. Place the file at: public/llms.txt
// 2. No code change needed, it's served at https://yoursite.com/llms.txt
// If you prefer to generate it dynamically:
// app/llms.txt/route.ts
import { NextResponse } from 'next/server';
export async function GET() {
const body = `# Acme
> One-line summary.
## Docs
- [Getting started](https://acme.example/docs/getting-started)
`;
return new NextResponse(body, {
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
});
}
Astro
// Astro, public/llms.txt is served as-is.
// Drop the file at: public/llms.txt
// Astro will copy it to dist/llms.txt during `astro build`.
// To generate it from your content collections, create:
// src/pages/llms.txt.ts
import type { APIRoute } from 'astro';
import { getCollection } from 'astro:content';
export const GET: APIRoute = async () => {
const docs = await getCollection('docs');
const body = [
'# Acme',
'',
'> Hosted analytics for product teams.',
'',
'## Documentation',
'',
...docs.map((d) => `- [${d.data.title}](https://acme.example/${d.slug}/): ${d.data.summary}`),
].join('\\n');
return new Response(body, { headers: { 'Content-Type': 'text/plain; charset=utf-8' } });
};
SvelteKit
// SvelteKit, static/llms.txt is served as-is.
// Drop the file at: static/llms.txt
// SvelteKit copies it to build/llms.txt during build.
// To generate it dynamically, create:
// src/routes/llms.txt/+server.ts
import type { RequestHandler } from './$types';
export const GET: RequestHandler = () => {
const body = `# Acme
> One-line summary.
## Docs
- [Getting started](https://acme.example/docs/getting-started)
`;
return new Response(body, {
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
});
};
Hugo
# Hugo, place llms.txt in the static/ folder.
# It will be copied to public/llms.txt during hugo build.
# To generate it from content, create a custom output format.
# config.toml:
[outputs]
home = ["HTML", "RSS", "LLMSTXT"]
[outputFormats.LLMSTXT]
name = "LLMSTXT"
mediaType = "text/plain"
baseName = "llms"
isPlainText = true
notAlternative = true
# layouts/index.llmstxt:
# {{ "# " }}{{ .Site.Title }}
#
# > {{ .Site.Params.description }}
#
# ## Pages
#
# {{ range .Site.RegularPages }}- [{{ .Title }}]({{ .Permalink }}): {{ .Params.summary }}
# {{ end }}
WordPress
# WordPress, three options
#
# 1. Easiest: upload llms.txt to your hosting (FTP/SFTP) at the web root.
# Verify: https://yoursite.com/llms.txt
#
# 2. Plugin: any "static file uploader" plugin works. Place file at root.
#
# 3. Programmatic: add a small handler to your theme's functions.php
# that intercepts the request and returns the file contents.
add_action('init', function () {
if (\$_SERVER['REQUEST_URI'] === '/llms.txt') {
header('Content-Type: text/plain; charset=utf-8');
echo file_get_contents(get_template_directory() . '/llms.txt');
exit;
}
});
Express
// Express, serve llms.txt as a static file or dynamic route.
// Option 1: static file in public/
app.use(express.static('public')); // serves public/llms.txt at /llms.txt
// Option 2: dynamic route
app.get('/llms.txt', (req, res) => {
res.type('text/plain');
res.send(`# Acme
> One-line summary.
## Docs
- [Getting started](https://acme.example/docs/getting-started)
`);
});
Laravel
<?php
// Laravel, add a route in routes/web.php
Route::get('/llms.txt', function () {
$content = <<<EOT
# Acme
> One-line summary.
## Docs
- [Getting started](https://acme.example/docs/getting-started)
EOT;
return response($content, 200)
->header('Content-Type', 'text/plain; charset=utf-8');
});
// Or use a controller:
// php artisan make:controller LlmsTxtController
// Then: Route::get('/llms.txt', [LlmsTxtController::class, 'show']);
CMS (Contentful وSanity وStrapi وPrismic)
# CMS-driven llms.txt (Contentful, Sanity, Strapi, Prismic…)
#
# Pattern: fetch curated entries at build time, write llms.txt.
#
# Node.js example (runs in CI or as a build script):
import { createClient } from 'contentful';
import fs from 'fs/promises';
const client = createClient({
space: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
});
const entries = await client.getEntries({ content_type: 'doc', 'fields.featured': true });
const lines = [
'# Acme',
'',
'> Hosted analytics for product teams.',
'',
'## Documentation',
'',
...entries.items.map(
(e) => `- [${e.fields.title}](https://acme.example/${e.fields.slug}/): ${e.fields.summary}`
),
];
await fs.writeFile('public/llms.txt', lines.join('\n'));
console.log(`Wrote ${entries.items.length} entries to llms.txt`);
أدلة منصات إضافية
أدلة خطوة بخطوة للحزم والمنشئات الشائعة الأخرى:
- Angular, Vue (Vite), Nuxt, Remix, Gatsby
- Docusaurus, MkDocs, Jekyll, Eleventy, صفحات GitHub
- Ruby on Rails, Django, Laravel, Express
- من دون كود: Framer, Webflow, Wix, Squarespace, Ghost, Shopify
المكدسات الأخرى
بالنسبة إلى ملف ثابت nginx, وانسخ الملف إلى جذر الويب لديك. القاعدة عامة: قدّم
الملف على المسار الأساسي /llms.txt
مع Content-Type: text/plain; charset=utf-8.
7. التوليد التلقائي وقت البناء
لا بأس بصيانة الملف يدوياً في موقع صغير، لكنها تتدهور سريعاً. ويوجد نمطان شائعان:
- نص البناء، وكرّر على مجموعة المحتوى لديك (Markdown أو MDX أو CMS)، ثم اكتب
llms.txtفيdist/. وأمثلة Astro وCMS أعلاه. - مسار الخادم، واعرض الملف عند الطلب من قاعدة بيانات أو نظام إدارة محتوى. وترد أمثلة Next.js وSvelteKit وExpress وLaravel أعلاه.
أيّاً كان اختيارك، شغّل المدقّق في CI: وسيلتقط الملفات المعطلة بصمت (مثل قسم فارغ بعد ترحيل المحتوى).
قائمة فحص قبل النشر
- الملف مقدَّم على
/llms.txtمع200 OK. Content-Type: text/plain; charset=utf-8.- عنوان H1 واحد بالضبط.
- ملخص اقتباس بلغة واضحة، بلا حشو تسويقي.
- جميع عناوين URL هي مطلق (
https://...). - يحتوي كل قسم على عنصر واحد على الأقل.
- لا توجد عناوين URL خاصة أو محمية بالمصادقة في القائمة.
- لا يعيد المدقق أي أخطاء.
-
إذا كان لديك corpus تريد كشفه، فانشر أيضاً
/llms-full.txt. -
robots.txtلا يزال يسمح بزحف الملف (لاDisallow: /llms.txt).
Next
- أفضل الممارسات، وما ينبغي مواصلته وما ينبغي تجنّبه.
- llms.txt وSEO، واستشهادات الذكاء الاصطناعي، وإشارات GEO، والترتيب.
- llms-full.txt, اكشف مجموعة محتواك الكاملة.
- أمثلة من العالم الحقيقي، انسخ ما ينجح.
- المدقّق · المولّد.