<!-- 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 لبناء الروابط من محتواك.

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

في هذه الصفحة

- [ الخيار 1: ملف ثابت في static/ ](#static)
- [ الخيار 2: التوليد في gatsby-node.js ](#gatsby-node)
- [ نهج إضافة Gatsby ](#plugin)
- [ تحقّق ](#verify)            
## الخيار 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/  ولو كان سيُنشأ عبر مسار صفحة Gatsby في المسار نفسه،
يفوز الملف الثابت. استفد من ذلك؛ يمكنك دائماً تجاوز الإخراج المنشأ يدوياً إذا لم يكن مناسباً تماماً.

## الخيار 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

إذا كنت تفضّل حلاً جاهزاً، فإن عدة إضافات مجتمعية تولّد `llms.txt` تلقائياً. ابحث في npm عن `gatsby-plugin-llms-txt`. وبدلاً من ذلك، يوجد النهج أعلاه في `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/)
