Overview
Thekosh build command processes your content, templates, and assets to generate a complete static site. It features intelligent caching to skip unchanged files and supports watch mode for automatic rebuilds.
Usage
Flags
Watch for file changes and automatically rebuild the site. Monitors
content/, template directory, static directory, and kosh.yaml.Write CPU profile to the specified file for performance analysis.
Write memory profile to the specified file for memory usage analysis.
Override the base URL from
kosh.yaml. Useful for building for different environments.Include draft posts in the build. Posts marked with
draft: true in frontmatter are normally excluded.Override the theme specified in
kosh.yaml.Examples
Build Process
The build command executes in the following order:-
Setup & Validation
- Acquires build lock to prevent concurrent builds
- Validates configuration and paths
- Checks for WASM updates
-
Static Assets (must complete first)
- Processes CSS, JavaScript, and images
- Generates content-hashed filenames for cache busting
- Populates the
Assetsmap used by templates
-
Content Processing
- Parses Markdown files with frontmatter
- Renders posts using templates
- Generates search indexes with BM25 scoring
- Creates social media cards
-
Global Pages
- Generates pagination pages
- Renders tag pages
- Creates 404 page
- Builds knowledge graph visualization
-
PWA Generation (if enabled)
- Generates manifest.json
- Creates service worker
- Generates app icons
-
Disk Synchronization
- Syncs virtual filesystem to disk
- Uses parallel worker pools for fast writes
Intelligent Caching
Kosh uses BLAKE3-based caching to skip rebuilding unchanged files:- Content Hash: Detects changes in Markdown source
- Body Hash: Tracks content-only changes (v1.2.1+)
- Template Tracking: Invalidates affected posts when templates change
- Dependency Detection: Rebuilds when global dependencies change
- Cache Rehydration: Restores from cache on template-only changes
Terminal Output
Performance Tips
- Use Watch Mode During Development: Incremental rebuilds are 5-10x faster than full builds
- Keep Cache Healthy: Run
kosh cache gcperiodically to remove orphaned data - Profile Slow Builds: Use
--cpuprofileto identify bottlenecks - Minimize Global Dependencies: Changes to
layout.htmltrigger full rebuilds
Related Commands
kosh serve- Build and serve with live reloadkosh clean- Clean output directorykosh cache- Manage build cache