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

- [ الرئيسية ](/ar/) 
/
- [ كيفية إنشاء ](/ar/how-to-create/) 
/
- دليل Cloudflare Pages            
# `llms.txt` مع Cloudflare Pages

نهجان: ضع ملفاً ثابتاً في دليل مخرجات البناء للنشر الفوري بلا إعداد، أو استخدم Cloudflare Pages Function للمحتوى الديناميكي.

آخر تحديث: 22 أبريل 2026

في هذه الصفحة

- [ النهج 1: ملف ثابت في ناتج البناء ](#approach-1)
- [ النهج 2، Cloudflare Pages Function ](#approach-2)
- [ البديل: Cloudflare Worker ](#workers)
- [ ترويسات التخزين المؤقت وسلوك CDN ](#cache)
- [ تحقّق بعد النشر ](#verify)              
مثال

يعمل هذا الموقع على Cloudflare Pages

يُنشر llmtxt.info على Cloudflare Pages عبر GitHub. وملفنا الخاص  /llms.txt 
يُقدَّم باستخدام نهج الملف الثابت (النهج 1 أدناه)، ويمكنك فحص الترويسات المباشرة باستخدام
curl -I https://llmtxt.info/llms.txt .

## النهج 1، ملف ثابت في مخرجات البناء

الخيار الأبسط. تقدّم Cloudflare Pages كل ملف في دليل ناتج البناء مباشرةً من CDN العالمي لديها.
لا Workers ولا Functions ولا تغييرات في الإعداد مطلوبة.
static file, framework directory map    نسخ     

```
# For any framework deployed on Cloudflare Pages,
# place llms.txt in the directory that gets published.
#
# Framework       → file location
# Astro           → public/llms.txt
# Next.js         → public/llms.txt
# SvelteKit       → static/llms.txt
# Hugo            → static/llms.txt
# Eleventy        → _site root (copy via passthrough)
# Plain HTML      → project root or output folder

# After deploy, Cloudflare serves it at /llms.txt from their global CDN.
# Verify:
curl -I https://your-domain.com/llms.txt
# Expected: HTTP/2 200 | Content-Type: text/plain | CF-Cache-Status: HIT
```

يعتمد الموقع الصحيح على إطار العمل لديك:

- **Astro** → `public/llms.txt` (منسوخ إلى `dist/` تلقائياً) 
- **Next.js** → `public/llms.txt` (يدعم محول Cloudflare Pages لـ Next.js هذا) 
- **SvelteKit** → `static/llms.txt` 
- **Hugo** → `static/llms.txt` 
- **Eleventy** → أضف نسخة عابرة: `eleventyConfig.addPassthroughCopy("llms.txt")` 
- **HTML عادي** → ضعه في المجلد الذي حددته كدليل مخرجات البناء   
بعد النشر، تخدّم Cloudflare الملف من شبكتها الطرفية حول العالم.
`Content-Type: text/plain` يُضبط الرأس تلقائياً استناداً إلى
`.txt` الامتداد.

مثال

تكامل GitHub

تتصل Cloudflare Pages مباشرةً بمستودع GitHub (أو GitLab) لديك. ويؤدي كل دفع إلى فرع الإنتاج إلى
تشغيل بناء ونشر جديدين. ويؤدي الالتزام  public/llms.txt 
هو كل ما تحتاج إليه؛ ولا توجد خطوة رفع يدوية.

## النهج 2، Cloudflare Pages Function

تتيح Cloudflare Pages Functions معالجة مسارات محددة بكود TypeScript يعمل على بيئة Cloudflare
Workers. أنشئ ملفاً في `functions/llms.txt.ts` ويعالج الطلبات تلقائياً إلى `/llms.txt`.
functions/llms.txt.ts, hardcoded content    نسخ     

```
// functions/llms.txt.ts
// Cloudflare Pages Functions use the file path as the route.
// This file handles GET requests to /llms.txt

interface Env {
// Add KV namespace or D1 bindings here if needed
}

export const onRequestGet: PagesFunction  = async (context) => {
// Build content, hardcode here or pull from KV / D1 / API
const content = [
'# My Site',
'',
'> One-sentence description of what this site is about.',
'',
'## Documentation',
'',
'- [Getting started](https://yoursite.com/docs/getting-started/): first steps.',
'- [API reference](https://yoursite.com/docs/api/): full endpoint catalog.',
'',
'## Optional',
'',
'- [Changelog](https://yoursite.com/changelog/): version history.',
].join('\n');

return new Response(content, {
headers: {
'Content-Type': 'text/plain; charset=utf-8',
// Cache at the edge for 1 hour, allow stale for 24h
'Cache-Control': 'public, max-age=3600, stale-while-revalidate=86400',
},
});
};

```

**متى تستخدم هذا:** عندما تريد توليد الملف من مصدر بيانات (قاعدة بيانات أو API لنظام
إدارة محتوى أو مخزن KV) دون إعادة بناء الموقع كله. مثال مع
[مساحة أسماء KV](https://developers.cloudflare.com/kv/):
functions/llms.txt.ts, KV-backed content    نسخ     

```
// functions/llms.txt.ts, pulling content from KV
// Useful if you update the file from a CMS webhook without redeploying.

interface Env {
LLMS_TXT: KVNamespace;
}

export const onRequestGet: PagesFunction  = async ({ env }) => {
const content = await env.LLMS_TXT.get('content');

if (!content) {
return new Response('# My Site\n\n> Content not configured yet.', {
status: 200,
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
});
}

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

```

مع نهج KV، يمكنك تحديث محتوى `/llms.txt` عن طريق الكتابة إلى مساحة أسماء KV (عبر API أو
لوحة التحكم أو خطاف ويب من CMS لديك) من دون تشغيل عملية نشر Pages كاملة.

تحذير

Pages Function مقابل ملف ثابت

إذا كان كلا  functions/llms.txt.ts  وصفحة ثابتة  llms.txt  إذا وُجدت في ناتج
البناء لديك، فستتقدم Pages Function عليها. استخدم نهجاً واحداً أو الآخر، لا كليهما.

## البديل: Cloudflare Worker

إذا لم يكن موقعك على Cloudflare Pages لكنه يستخدم Cloudflare كوكيل CDN/DNS، فيمكنك اعتراض `/llms.txt` المسار مع Cloudflare Worker مستقل باستخدام
[نمط المسار](https://developers.cloudflare.com/workers/configuration/routing/routes/):
Cloudflare Worker, standalone    نسخ     

```
// Cloudflare Worker, wrangler.toml config
// Use this if you want a standalone Worker (not tied to Pages).

// wrangler.toml
// name = "llms-txt-worker"
// main = "src/index.ts"
// compatibility_date = "2024-09-01"
//
// [[routes]]
// pattern = "yoursite.com/llms.txt"
// zone_name = "yoursite.com"

// src/index.ts
export default {
async fetch(request: Request): Promise  {
const content = `# My Site

> One-sentence description.

## Core pages

- [Getting started](https://yoursite.com/docs/getting-started/): first steps.
- [API reference](https://yoursite.com/docs/api/): full endpoint catalog.
`;

return new Response(content, {
headers: {
'Content-Type': 'text/plain; charset=utf-8',
'Cache-Control': 'public, max-age=3600',
},
});
},
} satisfies ExportedHandler;

```

## ترويسات التخزين المؤقت وسلوك CDN

تخزّن Cloudflare الملفات الثابتة من مخرجات البناء مؤقتاً تلقائياً. وبالنسبة إلى الملفات الثابتة،
لا تحتاج إلى ضبط ترويسات التخزين المؤقت؛ إذ تحترم Cloudflare مدة TTL الافتراضية من إعدادات مشروع
Pages لديك.

بالنسبة إلى Pages Functions، اضبط `Cache-Control` مذكورة صراحةً في الاستجابة. موصى به:

- `public, max-age=3600`، تخزيناً مؤقتاً على الحافة لمدة ساعة (مناسب للملفات المصانة
يدوياً). 
- `public, max-age=3600, stale-while-revalidate=86400`، وقدّم نسخة قديمة لمدة تصل إلى
24 ساعة أثناء إعادة التحقق في الخلفية. 
- `public, max-age=300`، وتخزين مؤقت لمدة 5 دقائق لمحتوى مدعوم بـ KV قد يتحدث
باستمرار.   
عند نشر إصدار جديد، تُبطل Cloudflare ذاكرة التخزين المؤقت تلقائياً للملفات الثابتة التي تغيرت.
أما Pages Functions، فاستخدم لوحة Cloudflare أو API لمسح عنوان URL المحدد إذا احتجت إلى إبطال
فوري.

## تحقّق بعد النشر
verify    نسخ     

```
# Check headers, look for Content-Type and CF-Cache-Status
curl -I https://yoursite.com/llms.txt

# Check content
curl https://yoursite.com/llms.txt

# Purge Cloudflare cache if you deployed a new version:
# Dashboard → Caching → Configuration → Purge Everything
# or via API:
curl -X POST "https://api.cloudflare.com/client/v4/zones/{ZONE_ID}/purge_cache" \
-H "Authorization: Bearer {CF_API_TOKEN}" \
-H "Content-Type: application/json" \
--data '{"files":["https://yoursite.com/llms.txt"]}'
```

بعد التحقق من الرؤوس، الصق عنوان URL المباشر في [المدقّق](/ar/validator/)
للتأكد من توافق المواصفة: H1 واحد بالضبط، وصياغة روابط صالحة، وجميع عناوين URL مطلقة، ولا أقسام فارغة.

&rarr; [دليل الإنشاء الكامل](/ar/how-to-create/) &middot;
[دليل Astro](/ar/llms-txt-astro/) &middot;
[دليل Next.js](/ar/llms-txt-nextjs/)

## المصادر

- [ llmstxt.org، اقتراح المجتمع ](https://llmstxt.org/)
- [ Cloudflare Pages، Functions ](https://developers.cloudflare.com/pages/functions/)
- [ Cloudflare، مثال حي لملف llms.txt ](https://www.cloudflare.com/llms.txt)
