הגדרת Decap CMS: folder, files, widgets — התקנה מלאה ביום אחד
לעתים קרובות אנו נתקלים במצבים שבהם CMS הופך ל"קופסה שחורה" לאחר ההגדרה: עורכים מתבלבלים עם שדות, תוכן נשמר במקום הלא נכון, וכתובות slug מתנגשות. הכל מסתכם בקובץ YAML אחד — config.yml. הגדרה נכונה של אוספי Decap CMS אינה רק רשימת שדות, אלא ארכיטקטורת תוכן. אם חושבים על זה מראש, חוסכים שעות של עריכות ותסכול. במשך 6 שנות עבודה על פרויקטים עם Decap CMS, פיתחנו גישות שעוזרות להימנע מטעויות נפוצות. לדוגמה, הגדרת אוספים לחנות מקוונת עם קטלוג מוצרים, קטגוריות ומותגים ארכה 6 שעות. לאחר ההטמעה, עורכים יוצרים מוצרים פי 2 מהר יותר, ומספר שגיאות הפרסום ירד ב-40%.
שני סוגי אוספים: folder לעומת files
| פרמטר | אוסף folder | אוסף files |
|---|---|---|
| מטרה | מספר רשומות דומות (מאמרים, מוצרים) | עמודים קבועים (בית, צור קשר) |
| יצירת רשומות חדשות | כן (create: true) | לא, רק עריכה |
| Slug | נוצר מתבנית | לא נדרש |
| דוגמה | בלוג, קטלוג, ביקורות | בית, אודות, 404 |
---
collections: # Folder collection
- name: blog
label: Блог
folder: content/blog
create: true
delete: true
slug: "{{slug}}"
fields:
- { label: Заголовок, name: title, widget: string }
- { label: Контент, name: body, widget: markdown }
# Files collection
- name: pages
label: Страницы
files:
- label: Главная страница
name: home
file: content/home.yaml
fields:
- { label: Заголовок hero, name: hero_title, widget: string }
- { label: Подзаголовок, name: hero_subtitle, widget: text }
- label: О компании
name: about
file: content/about.md
fields:
- { label: Заголовок, name: title, widget: string }
- { label: Контент, name: body, widget: markdown }
--- הגדרת אוספים לסוגי תוכן שונים
עבור אתר אינפורמטיבי, שני אוספים מספיקים: מאמרים (folder) ועמודים (files). עבור חנות מקוונת, יש צורך בקטלוג מוצרים, קטגוריות ומותגים. כלל: סוג תוכן אחד — אוסף אחד. אל תנסו לדחוס מוצרים ומאמרים לתיקייה אחת, אחרת תעמיסו על הממשק. אוסף folder עדיף לבלוג מאשר אוסף files, מכיוון שהוא מאפשר יצירת רשומות חדשות ללא שינוי בקונפיגורציה.
ווידג'טים: סט מלא לפרויקטים אמיתיים
fields: # Базовые
- { label: Строка, name: title, widget: string, required: true }
- { label: Текст, name: description, widget: text }
- { label: Число, name: order, widget: number, value_type: int, default: 0 }
- { label: Булево, name: featured, widget: boolean, default: false }
- { label: Дата, name: date, widget: datetime, format: "YYYY-MM-DD" }
# Выбор из списка
- label: Категория
name: category
widget: select
options:
- { label: Новости, value: news }
- { label: Кейсы, value: cases }
- { label: Аналитика, value: analytics }
# Медиафайл
- { label: Обложка, name: cover, widget: image, required: false }
# Markdown-редактор
- label: Контент
name: body
widget: markdown
modes: [rich_text, raw]
# Список строк
- { label: Теги, name: tags, widget: list, required: false }
# Вложенный объект (SEO)
- label: SEO
name: seo
widget: object
collapsed: true
fields:
- { label: Meta title, name: title, widget: string, required: false }
- { label: Meta description, name: description, widget: text, required: false }
- { label: OG Image, name: og_image, widget: image, required: false }
# Список объектов (преимущества)
- label: Преимущества
name: features
widget: list
fields:
- { label: Иконка, name: icon, widget: string }
- { label: Заголовок, name: title, widget: string }
- { label: Описание, name: description, widget: text }Decap CMS מציע למעלה מ-12 סוגי ווידג'טים; כיסינו את השימושיים ביותר. לדוגמה, שימוש ב-collections: # Folder collection - name: blog label: Блог folder: content/blog create: true delete: true slug: "{{slug}}" fields: - { label: Заголовок, name: title, widget: string } - { label: Контент, name: body, widget: markdown } # Files collection - name: pages label: Страницы files: - label: Главная страница name: home file: content/home.yaml fields: - { label: Заголовок hero, name: hero_title, widget: string } - { label: Подзаголовок, name: hero_subtitle, widget: text } - label: О компании name: about file: content/about.md fields: - { label: Заголовок, name: title, widget: string } - { label: Контент, name: body, widget: markdown } במקום select ידני מפחית כפילויות נתונים פי 3.
חשיבות הגדרת ווידג'טים נכונה
בחירת ווידג'ט שגויה מובילה לבעיות עריכה. לדוגמה, השתמשו ב-markdown לטקסטים ארוכים, לא ב-text — אחרת העורך לא יכול לעצב. עבור ערכים מספריים, ציינו תמיד fields: # Базовые - { label: Строка, name: title, widget: string, required: true } - { label: Текст, name: description, widget: text } - { label: Число, name: order, widget: number, value_type: int, default: 0 } - { label: Булево, name: featured, widget: boolean, default: false } - { label: Дата, name: date, widget: datetime, format: "YYYY-MM-DD" } # Выбор из списка - label: Категория name: category widget: select options: - { label: Новости, value: news } - { label: Кейсы, value: cases } - { label: Аналитика, value: analytics } # Медиафайл - { label: Обложка, name: cover, widget: image, required: false } # Markdown-редактор - label: Контент name: body widget: markdown modes: [rich_text, raw] # Список строк - { label: Теги, name: tags, widget: list, required: false } # Вложенный объект (SEO) - label: SEO name: seo widget: object collapsed: true fields: - { label: Meta title, name: title, widget: string, required: false } - { label: Meta description, name: description, widget: text, required: false } - { label: OG Image, name: og_image, widget: image, required: false } # Список объектов (преимущества) - label: Преимущества name: features widget: list fields: - { label: Иконка, name: icon, widget: string } - { label: Заголовок, name: title, widget: string } - { label: Описание, name: description, widget: text } ו-value_type כדי למנוע שדות ריקים. אנו מבטיחים שלאחר ההגדרה שלנו, עורכים לא יתקלו בבעיות כאלה.
מיון וסינון
לנוחות העורכים, הוסיפו default ו-sortable_fields. זה מאפשר מיון רשומות לפי תאריך, כותרת או שדה מותאם אישית, וסינון לפי סטטוס.
---
- name: team
label: Команда
folder: content/team
create: true
sortable_fields: ['name', 'position', 'order']
view_filters:
- label: Только активные
field: active
pattern: true
- label: Менеджеры
field: department
pattern: management
view_groups:
- label: По отделу
field: department
אוספים קשורים באמצעות relation
שדה view_filters מקבל פרמטרים: - name: team label: Команда folder: content/team create: true sortable_fields: ['name', 'position', 'order'] view_filters: - label: Только активные field: active pattern: true - label: Менеджеры field: department pattern: management view_groups: - label: По отделу field: department — שם אוסף המקור, relation — שדות לחיפוש, collection — מה נשמר בקובץ. לדוגמה: search_fields. בקובץ ה-markdown, שם המחבר נשמר כמחרוזת. אם יש צורך במזהה (ID) — שנה את value_field.
הגדרות מתקדמות: מקונן ומותנה
---
- name: docs
label: Документация
folder: content/docs
create: true
nested:
depth: 3
summary: "{{title}}"
meta:
path:
label: Путь
widget: parent-path
fields:
- label: Тип блока
name: type
widget: select
options: [text, video, gallery]
- label: Текст
name: text
widget: markdown
condition:
field: type
value: text
- label: URL видео
name: video_url
widget: string
condition:
field: type
value: video
i18n של אוספים
i18n:
structure: multiple_files
locales: [ru, en]
default_locale: ru
collections:
- name: services
label: Услуги
folder: content/services
create: true
i18n: true
fields:
- { label: Заголовок, name: title, widget: string, i18n: true }
- { label: Слаг, name: slug, widget: string, i18n: duplicate }
- { label: Контент, name: body, widget: markdown, i18n: true } טעויות נפוצות וכיצד להימנע מהן
| טעות | השלכות | פתרון |
|---|---|---|
| לא צוין folder עבור אוסף folder | קבצים נוצרים בשורש GitHub | ציינו תמיד widget: relation, collection: team, search_fields: ['name'], value_field: name |
| יותר מדי שדות חובה | עורכים מתעייפים ומדלגים על שדות חשובים | השאירו רק שדות מפתח כשדות חובה |
| relation ללא search_fields | התפריט הנפתח הופך לאינסופי | הוסיפו לפחות value_field: "{{slug}}" |
| חסר default_locale עם i18n | ה-build נכשל, CMS לא יכול לזהות שפה | ציינו - name: docs label: Документация folder: content/docs create: true nested: depth: 3 summary: "{{title}}" meta: { path: { label: Путь, widget: parent-path } } fields: - label: Тип блока name: type widget: select options: [text, video, gallery] - label: Текст name: text widget: markdown condition: field: type value: text - label: URL видео name: video_url widget: string condition: field: type value: video |
מה כלול בהגדרת אוספי Decap CMS
- פיתוח סכמת תוכן לפרויקט שלכם (5–8 סוגי תוכן).
- הגדרת ווידג'טים, relation, nested, i18n.
- בדיקה על נתונים אמיתיים (עד 50 רשומות).
- תיעוד לעורכים (תיאור כל שדה).
- תמיכה למשך שבועיים לאחר המסירה — אנו מתקנים ליקויים.
תוצרים
- תיעוד מפורט (Notion או Markdown) המסביר כל אוסף ושדה.
- גישת אדמין ל-Decap CMS עם נתוני בדיקה (עד 50 רשומות).
- הדרכה של שעה לעורכים באמצעות Zoom.
- שבועיים של תמיכה לאחר המסירה באמצעות Slack או דוא"ל.
- קבצי קונפיגורציה שנדחפים ל-repository שלכם עם היסטוריית git נקייה.
כיצד לנפות באגים בקונפיגורציית Decap CMS?
הסיבות הנפוצות ביותר ל-CMS שאינו עובד לאחר עריכת i18n: structure: multiple_files locales: [ru, en] default_locale: ru collections: - name: services label: Услуги folder: content/services create: true i18n: true fields: - { label: Заголовок, name: title, widget: string, i18n: true } - { label: Слаг, name: slug, widget: string, i18n: duplicate } - { label: Контент, name: body, widget: markdown, i18n: true } :
- תחביר YAML — רווח אחד נוסף או חסר שובר את מבנה הקובץ, וה-CMS לא נטען. בדקו עם validator מקוון לפני הדחיפה.
- נתיב backend שגוי — ודאו ש-
folderתואם לספק שלכם, וש-search_fields: ['name']מצביע על הענף הנכון ב-repository. - שדות חובה ריקים — אם עורך לא יכול לשמור רשומה, בדקו שכל השדות עם
default_localeכולליםconfig.yml. - relation לא מוצא אוסף — שדה
name: git-gatewayבווידג'ט relation חייב להתאים ל-branchשל אוסף היעד, לא ל-required: true. - קבצי i18n לא נוצרים — עם
default, יש צורך בתיקייה נפרדת לכל שפה.
כיצד אנו מיישמים הגדרת אוספי Decap CMS?
- מקיימים ראיונות עם עורכים — מגלים אילו שדות נמצאים בשימוש התכוף ביותר ומה גורם לקשיים.
- מעצבים את סכמת האוספים: מגדירים סוגים, ווידג'טים וקשרים בין אוספים.
- כותבים
collection, בודקים על staging — יוצרים, עורכים, מוחקים רשומות. - מתעדים כל שדה, מסבירים את מטרת הווידג'טים לצוות העריכה.
- מוסרים עם תמיכה של שבועיים — מתקנים הערות במהירות.
לוחות זמנים ועלות
הגדרה בסיסית (עד 5 אוספים, ללא i18n): 4–8 שעות ($500–$1000). פרויקט בינוני (6–10 אוספים, relation): יום אחד ($1000–$2000). פרויקט מורכב (עם i18n, שדות מותנים, 10–15 אוספים): 1–2 ימים ($2000–$4000). העלות נקבעת לאחר ניתוח. צרו קשר כדי לדון בהגדרת Decap CMS שלכם. קבלו ייעוץ ממהנדס עם 6 שנות ניסיון עם CMS זה. אנו מבטיחים איכות ועמידה בלוחות זמנים.







