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

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

نهجان في Gatsby: ملف ثابت في static/ لا يحتاج إلى إعداد، أو إنشاء برمجي في gatsby-node.js باستخدام طبقة بيانات GraphQL لبناء الروابط من محتواك.

آخر تحديث: 29 أكتوبر 2026

في هذه الصفحة

- [ الخيار 1: ملف ثابت في static/ ](#static)
- [ الخيار 2: التوليد في gatsby-node.js ](#gatsby-node)
- [ إضافة مجتمعية: gatsby-plugin-llms-txt ](#plugin)
- [ تحقّق ](#verify)               
ملاحظة

حالة المشروع

يخضع Gatsby لتطوير محدود. ففي 21 نوفمبر 2024 وصف أحد مشرفي Gatsby مستوى العمل الحالي في نقاش
GitHub رقم 39062 بأنه إصلاحات أمنية، وتحديثات محدودة للتبعيات، وإصلاحات للأخطاء السهلة، وتحسينات
في الأداء، ومعالجة حالات إيقاف واجهات API الخارجية القادمة. وأحدث إصدار من  gatsby  على
npm هو 5.16.1 (10 فبراير 2026). ويعتمد كلا النهجين أدناه فقط على ميزات Gatsby القائمة منذ زمن طويل.

## الخيار 1: ملف ثابت في static/

ينسخ Gatsby كل شيء في `static/` الدليل مباشرةً إلى `public/` ناتج البناء. ضع ملفك في `static/llms.txt` 
وسيصبح متاحاً على `/llms.txt` بعد `gatsby build`.
static/llms.txt, directory structure    نسخ     

```
# Gatsby static file approach
#
# Place your file at: static/llms.txt
# Gatsby copies everything in static/ directly to the public/ build output.
#
# Project structure:
# your-gatsby-site/
# ├── static/
# │   └── llms.txt   ← add this
# ├── src/
# └── gatsby-config.js

```

لا يتطلب هذا النهج تغييرات في الكود ويعمل مع جميع أهداف نشر Gatsby: **Netlify**, **Vercel**, **Cloudflare Pages**, **AWS Amplify**, ومستضاف ذاتياً.

مثال

اختر مصدراً واحداً للملف

استخدم إما  static/llms.txt  وإما مولّداً وقت البناء (الخيار 2 أو إضافة)، لا كليهما، بحيث
تكتب آلية واحدة فقط  public/llms.txt .

## الخيار 2: التوليد في gatsby-node.js

بالنسبة إلى المواقع التي تأتي صفحات توثيقها من Markdown أو MDX أو CMS عبر طبقة بيانات Gatsby،
استخدم `onPostBuild` خطاف دورة الحياة في `gatsby-node.js` لتوليد `llms.txt` بعد اكتمال البناء. ويضمن ذلك بقاء قائمة الروابط
متزامنة دائماً مع محتواك.
gatsby-node.js    نسخ     

```
// gatsby-node.js
// Generate llms.txt from your GraphQL data layer
const { writeFileSync } = require('fs');
const { resolve } = require('path');

exports.onPostBuild = async ({ graphql }) => {
// Query your documentation pages (adjust the query to your data model)
const result = await graphql(`
query {
allMarkdownRemark(
filter: { frontmatter: { collection: { eq: "docs" } } }
sort: { frontmatter: { order: ASC } }
) {
nodes {
frontmatter {
title
description
}
fields {
slug
}
}
}
}
`);

if (result.errors) {
throw result.errors;
}

const docs = result.data.allMarkdownRemark.nodes;
const siteUrl = 'https://yoursite.com';

const links = docs
.map(
(doc) =>
`- [${doc.frontmatter.title}](${siteUrl}/docs/${doc.fields.slug}/): ${doc.frontmatter.description ?? ''}`
)
.join('\n');

const content = [
'# Your Site',
'',
'> One-sentence description of your project.',
'',
'## Documentation',
'',
links,
'',
'## Optional',
'',
`- [Changelog](${siteUrl}/changelog/): Release history.`,
].join('\n');

// Write to public/ (Gatsby's build output directory)
writeFileSync(resolve(__dirname, 'public', 'llms.txt'), content, 'utf-8');
};

```

الـ `onPostBuild` تتلقى الخطاف نفسه `graphql` الدالة المستخدمة في استعلامات
الصفحات. عدّل الاستعلام ليلائم نموذج بياناتك؛ يستخدم المثال `allMarkdownRemark` لكن يمكنك
الاستعلام من أي إضافة مصدر لـ Gatsby (`allMdx`, `allContentfulPage`وما إلى
ذلك).

## إضافة مجتمعية: gatsby-plugin-llms-txt

`gatsby-plugin-llms-txt` إضافة **مجتمعية**، وليست حزمة Gatsby رسمية
(الإصدار 1.0.1، المنشور في 28 سبتمبر 2025). في خطافها `onPostBuild` تنفّذ استعلام GraphQL
تقدّمه أنت، وتقرأ الحقل المحدد في `contentPath` وتكتب قيمته إلى `public/llms.txt`؛ وإذا كان الحقل فارغاً فلا يُنشأ أي ملف. وتناسب المواقع التي تحفظ النص الكامل لـ `llms.txt`
في حقل داخل CMS. ويذكر ملف README الخاص بها أن Gatsby v4 وv5 مدعومان.
gatsby-config.js, gatsby-plugin-llms-txt    نسخ     

```
// npm install gatsby-plugin-llms-txt
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-llms-txt',
options: {
// GraphQL query returning the llms.txt text (example: a CMS settings document)
query: `
query {
settings {
llmsTxt
}
}
`,
// Dot path to the field that holds the content in the query result
contentPath: 'settings.llmsTxt',
},
},
],
};
```

لا تبني الإضافة قائمة روابط من صفحاتك. ولاشتقاق القائمة من المحتوى، يظل نهج
`gatsby-node.js` أعلاه هو الطريق المباشر.

يمكنك أيضاً استخدام **gatsby-plugin-sitemap** كمرجع، فهو يستخدم النحو نفسه `onPostBuild` نمطاً لكتابة ملف XML إلى `public/`.

## تحقّق
Build and verify    نسخ     

```
# Build
gatsby build

# Check generated file
cat public/llms.txt | head -10

# After deploying, verify the live URL
curl -I https://yoursite.com/llms.txt
# Expected: content-type: text/plain; charset=utf-8
```

## أدلة ذات صلة

- [كيفية إنشاء llms.txt](/ar/how-to-create/), والقوالب وقائمة الفحص. 
- [مرجع تنسيق llms.txt](/ar/llms-txt-format/), تفاصيل المواصفة. 
- [دليل Eleventy](/ar/llms-txt-eleventy/)، نهج آخر لمولّد مواقع ثابتة. 
- [دليل Next.js](/ar/llms-txt-nextjs/), إطار React مع SSR. 
- [المدقّق](/ar/validator/) · [المولّد](/ar/generator/).         
## المصادر

- [ llmstxt.org، اقتراح المجتمع ](https://llmstxt.org/)
- [ توثيق Gatsby، والدليل الثابت ](https://www.gatsbyjs.com/docs/how-to/images-and-media/static-folder/)
- [ توثيق Gatsby، وgatsby-node.js ](https://www.gatsbyjs.com/docs/reference/config-files/gatsby-node/)
- [ نقاش GitHub رقم 39062، رد المشرف بتاريخ 2024-11-21 حول حالة Gatsby ](https://github.com/gatsbyjs/gatsby/discussions/39062)
- [ npm، gatsby (5.16.1) ](https://www.npmjs.com/package/gatsby)
- [ npm، gatsby-plugin-llms-txt (مجتمعية، 1.0.1) ](https://www.npmjs.com/package/gatsby-plugin-llms-txt)
