Schemas define the structure of your content's frontmatter—the YAML metadata at the top of each markdown file. With md0 CMS, you can create schemas using a visual interface instead of editing raw YAML.
What is a Schema?
A schema is a set of fields that define:
- What information each content file should have
- The type of each field (string, date, boolean, etc.)
- Which fields are required vs optional
- Default values for fields
- Validation rules
Creating a Schema
Access Schema Editor
- Navigate to your collection
- Click "Schema" or "Edit Schema"
- You'll see the schema configuration interface
Adding Fields
Click "Add Field" and configure:
Field Name: title
Field Type: string
Required: true
Description: The post title
Default Value: (empty)
Field Types
String
Short single-line text input.
name: title
type: string
required: true
placeholder: "Enter post title"
Use for:
- Titles
- Names
- Short descriptions
- URLs
- Tags (single)
Frontmatter output:
title: "Getting Started with md0 CMS"
Text
Multi-line text area for longer content.
name: excerpt
type: text
required: false
maxLength: 300
placeholder: "Brief summary of the post"
Use for:
- Descriptions
- Excerpts
- Meta descriptions
- Summaries
Frontmatter output:
excerpt: |
This guide will walk you through
the basics of setting up md0 CMS.
Number
Numeric input with optional min/max validation.
name: order
type: number
required: false
min: 0
max: 100
default: 0
Use for:
- Sort order
- Reading time
- View counts
- Numeric IDs
Frontmatter output:
order: 1
Boolean
True/false toggle switch.
name: published
type: boolean
required: true
default: false
Use for:
- Published status
- Featured flags
- Enable/disable options
- Visibility toggles
Frontmatter output:
published: true
featured: false
Date
Date picker with optional time.
name: date
type: date
required: true
default: now
format: "YYYY-MM-DD"
Use for:
- Publication dates
- Last updated timestamps
- Event dates
- Scheduling
Frontmatter output:
date: 2024-01-15
DateTime
Date and time picker.
name: publishedAt
type: datetime
required: true
default: now
format: "YYYY-MM-DD HH:mm:ss"
Frontmatter output:
publishedAt: 2024-01-15 14:30:00
Array
List of items (strings, numbers, etc.).
name: tags
type: array
items: string
required: false
Use for:
- Tags
- Categories
- Authors (multiple)
- Keywords
Frontmatter output:
tags:
- markdown
- cms
- github
Select
Dropdown with predefined options.
name: category
type: select
required: true
options:
- Tutorial
- Guide
- News
- Case Study
Use for:
- Categories
- Status (draft, published, archived)
- Type selection
- Priority levels
Frontmatter output:
category: Tutorial
Image
Image upload with URL storage.
name: featured_image
type: image
required: false
folder: /public/images/posts
Use for:
- Featured images
- Author avatars
- Cover photos
- Thumbnails
Frontmatter output:
featured_image: /images/posts/hero-image.jpg
Object
Nested fields for complex data.
name: author
type: object
fields:
- name: name
type: string
- name: email
type: string
- name: avatar
type: image
Frontmatter output:
author:
name: "Jane Doe"
email: "jane@example.com"
avatar: "/images/authors/jane.jpg"
Field Options
Required Fields
Mark fields as required to ensure they're always filled:
name: title
type: string
required: true # Content cannot be saved without this field
Default Values
Set default values for new content:
name: published
type: boolean
default: false # New posts start as drafts
name: author
type: string
default: "Admin"
Field Validation
String Validation
name: slug
type: string
pattern: "^[a-z0-9-]+$" # Only lowercase letters, numbers, hyphens
minLength: 3
maxLength: 100
Number Validation
name: rating
type: number
min: 1
max: 5
Array Validation
name: tags
type: array
minItems: 1
maxItems: 5
Field Descriptions
Add helpful hints for content editors:
name: excerpt
type: text
description: "A brief summary shown in post listings. Aim for 2-3 sentences."
Schema Examples
Blog Post Schema
fields:
- name: title
type: string
required: true
- name: date
type: date
required: true
default: now
- name: excerpt
type: text
required: true
maxLength: 200
- name: author
type: string
required: true
default: "Admin"
- name: tags
type: array
items: string
- name: category
type: select
options:
- Tutorial
- Guide
- News
- name: featured_image
type: image
- name: published
type: boolean
default: false
Documentation Schema
fields:
- name: title
type: string
required: true
- name: description
type: text
required: true
- name: order
type: number
default: 0
description: "Order in sidebar navigation"
- name: category
type: select
options:
- Getting Started
- Guides
- API Reference
- name: last_updated
type: date
default: now
Product Schema
fields:
- name: name
type: string
required: true
- name: description
type: text
required: true
- name: price
type: number
required: true
min: 0
- name: images
type: array
items: image
- name: in_stock
type: boolean
default: true
- name: category
type: select
options:
- Electronics
- Clothing
- Books
Advanced Schema Features
Conditional Fields
Show fields based on other field values:
- name: post_type
type: select
options:
- Article
- Video
- name: video_url
type: string
condition:
field: post_type
equals: Video
Field Groups
Organize related fields:
- name: seo
type: object
fields:
- name: meta_title
type: string
- name: meta_description
type: text
- name: keywords
type: array
items: string
Schema Best Practices
Keep It Simple
- Start with essential fields only
- Add fields as needed
- Avoid over-complicating schemas
- Consider editor experience
Use Appropriate Types
- Use
selectfor limited options - Use
booleaninstead of yes/no strings - Use
datefor dates, not strings - Use
numberfor numeric values
Provide Clear Labels
# Good
name: featured_image
label: "Featured Image"
description: "Main image shown at the top of the post"
# Bad
name: img1
label: "img1"
Set Sensible Defaults
# For blog posts
published: false # Draft by default
date: now # Current date
author: "Admin" # Default author
Validate Input
Use validation to prevent errors:
# Slug validation
pattern: "^[a-z0-9-]+$"
# Email validation
pattern: "^[^@]+@[^@]+\.[^@]+$"
# URL validation
pattern: "^https?://"
Editing Schemas
Modifying Existing Schemas
- Go to Collection > Schema
- Edit, add, or remove fields
- Save changes
Note: Changing schemas doesn't automatically update existing content—only new or edited content will use the new schema.
Migrating Content
When you change schemas significantly:
- Export existing content
- Update schema
- Batch update content if needed
- Test with sample content
Schema Validation
md0 CMS validates content against your schema:
- Required fields: Must be filled
- Type validation: Values must match field type
- Pattern validation: Strings must match regex
- Range validation: Numbers must be within min/max
Validation errors appear in the editor before saving.
Troubleshooting
Frontmatter Not Parsing
Check:
- YAML syntax is correct
- Indentation is consistent
- Quotes are balanced
- Special characters are escaped
Fields Not Appearing
Check:
- Schema is saved
- Field name matches frontmatter key
- Field type is appropriate
- Cache is cleared
Validation Errors
Check:
- Required fields are filled
- Values match field types
- Pattern matches regex
- Numbers are within range
Next Steps
After defining your schema:
- Create Content using your schema
- Configure Collections for advanced patterns
- Integrate with Your Site to use the content
Related Documentation
- Collection Patterns - Advanced collection configuration
- Schema Configuration - Detailed schema options
- Markdown Editing - Using the editor