Post Frontmatter
Frontmatter is YAML metadata at the top of markdown files that controls how posts are rendered, organized, and displayed.Format
Frontmatter must be enclosed in triple-dashes (---) at the start of the file:
Required Fields
Post title displayed in Best Practices:
<h1>, page title, search results, and RSS feed.- Use descriptive, unique titles
- Aim for 40-60 characters for SEO
- Avoid special characters that break URLs
Publication date in Note: Future dates don’t prevent publication (no scheduling feature).
YYYY-MM-DD format. Used for sorting and RSS pubDate.Optional Fields
Brief summary for meta descriptions, social cards, and post previews.Best Practices:
- Keep under 160 characters for SEO
- Write compelling copy for social shares
- Avoid duplicating the title
Array of tag strings for categorization. Tags are:Formatting:Best Practices:
- Displayed on post pages
- Linked to tag index pages
- Used in search filtering (
tag:golang) - Visualized in knowledge graph
- Use 2-5 tags per post
- Use lowercase with hyphens for multi-word tags
- Be consistent across posts
Pin post to the top of index pages. Pinned posts appear before regular posts regardless of date.Use Cases:
- Important announcements
- “Start here” guides
- Featured content
Mark post as draft. Excluded from builds unless Preview Drafts:Note: Drafts are:
-drafts flag is used.- Excluded from sitemap and RSS
- Not indexed in search
- Not counted in build metrics
Custom sort order for documentation sites. Higher weight = appears first.Use Cases:Note: Posts with equal weight are sorted by date.
- Control sidebar order in docs theme
- Override chronological sorting
- Group related pages together
Custom social card image path. Overrides auto-generated social card.Path Formats:
- Relative to
outputDir:/static/images/card.jpg - Absolute URL:
https://example.com/card.jpg
- Size: 1200x630px (Open Graph standard)
- Format: JPG or PNG (WebP not widely supported)
- File size: <200KB for fast loading
socialCards config.Auto-Generated Fields
These fields are computed during build and cannot be overridden:Estimated reading time in minutes, calculated from word count.Algorithm:
wordCount / 200 words per minute (rounded up)Access in Templates:Generated URL path for the post, derived from filename.Slugification:
content/my-post.md→/my-post.htmlcontent/getting-started.md→/getting-started.htmlcontent/v2.0/api.md→/v2.0/api.html
Version path for versioned documentation (empty string for latest).Example:
content/intro.md→version: ""content/v3.0/intro.md→version: "v3.0"
Complete Example
content/blog/kosh-performance-guide.md
Versioned Documentation
For versioned docs (usingdocs theme), place files in version subdirectories:
content/v4.0/getting-started.md
content/v4.0/getting-started.md→/v4.0/getting-started.htmlcontent/getting-started.md→/getting-started.html(latest)
Template Access
Frontmatter fields are available in templates via thePageData struct:
templates/post.html
Search Integration
Frontmatter is indexed for search:title- Full-text search with BM25 scoringdescription- Included in search snippetstags- Filterable withtag:prefixcontent- Body text searchable with stemming
Common Patterns
Common Patterns
Validation
Kosh validates frontmatter at build time: Missing Required Fields:YAML Tips
Quotes
Quote strings containing special characters:Multi-line Strings
Boolean Values
Arrays
Metadata in Templates
Access raw frontmatter via.Meta map: