build()
Generate a static site from a configuration object. Returns a GenerateStaticResult describing what was written.
import { build } from 'sovrium'
const result = await build({ name: 'my-site', pages: [{ name: 'Home', path: '/' }] })
console.log(result.outputDir) // "./static"
console.log(result.files.length)
Like start(), build() validates against AppSchema first and rejects with Sovrium failed to build: rather than emitting a partial site.
GenerateStaticOptions
| Property | Description |
|---|---|
outputDir |
Output directory. Default: ./static. |
baseUrl |
Base URL for sitemap and canonical links. |
basePath |
Path prefix for subdirectory deployments. |
deployment |
Target platform: github-pages or generic. |
languages |
Array of language codes to generate. |
defaultLanguage |
Default language code. |
generateSitemap |
Generate sitemap.xml. Default: false. |
generateRobotsTxt |
Generate robots.txt. Default: false. |
hydration |
Emit the client-side hydration runtime. Default: false. |
generateManifest |
Generate manifest.json for PWA. Default: false. |
bundleOptimization |
Splitting strategy: split or none. |
publicDir |
Static asset directory to copy into the output. |
outputDir differs from the CLI. Calling build() directly defaults to ./static, relative to the working directory. sovrium build app.yaml instead defaults to a dist/ directory beside the config file. Pass outputDir explicitly whenever both paths exist in one project.
GenerateStaticResult
| Property | Description |
|---|---|
outputDir |
Path to the output directory that was written. |
files |
Every file generated during the build (HTML, CSS, assets, sitemap). |
The files array is the deploy manifest — enumerate it rather than re-walking the directory, since it excludes anything that was already there.
A full static build
import { build } from 'sovrium'
import type { GenerateStaticResult } from 'sovrium'
const result: GenerateStaticResult = await build(
{
name: 'my-site',
pages: [
{
name: 'Home',
path: '/',
components: [
{ type: 'hero', content: 'Welcome' },
{ type: 'text', content: 'Built with Sovrium.' },
],
},
],
},
{
outputDir: './dist',
baseUrl: 'https://example.com',
deployment: 'github-pages',
generateSitemap: true,
generateRobotsTxt: true,
}
)
console.log(`Wrote ${result.files.length} files to ${result.outputDir}`)
deployment: 'github-pages' adds the files that host needs — notably a .nojekyll marker so directories beginning with an underscore are served instead of being swallowed by Jekyll.
Page search
If any page declares a pageSearch component, build() also runs the search indexer and writes a sovrium-search/ directory into the output. The extra files appear in result.files. With no such component nothing is emitted and no indexing cost is paid — the feature is gated on the config, not on a flag.
Related Pages
- TypeScript API Overview —
AppConfigand the other functions. - Project Commands —
sovrium buildand itsSOVRIUM_*variables. - SEO & Metadata — what
baseUrland the sitemap feed. - Search Overview — the
pageSearchcomponent.
Last updated July 27, 2026
This documentation was written with AI, so errors or outdated content are possible. Sovrium is in beta — contributions and corrections are welcome.