Getting Started #

This guide creates a small but complete KawaPress site. By the end, you will have Markdown pages, a default documentation interface, a local development server, and static files ready to deploy.

Prerequisites #

You need:

  • Node.js 22.12 or later;
  • npm, pnpm, or Yarn;
  • an editor with Markdown support.

Create with the Scaffolder #

The fastest way to start is the create-kawapress scaffolder. It prepares the configuration file, a home page, and one example page in the directory you name, so the site runs right away.

Shell
npm create kawapress@latest my-kawapress-site

While it runs, it asks for the site title, the default language, and whether to install dependencies. Add --yes to accept every default without any questions:

Shell
npm create kawapress@latest my-kawapress-site --yes

The other flags are --title, --lang, --second-lang, --pm, and --install / --no-install. Run the command with --help to see them all.

Once it finishes, enter the directory and start the development server:

Shell
cd my-kawapress-site
npm run dev

The sections below build the same site by hand, starting from an empty directory. Follow them if you want to know what each file does, or if you are adding KawaPress to a project you already have.

Create a Project #

Create a directory and initialize its package.json:

Shell
mkdir my-kawapress-site
cd my-kawapress-site
npm init -y

KawaPress treats the current working directory as the site root. Site configuration, Markdown pages, and build output are all resolved from this directory.

Install KawaPress #

A site using the built-in nagi (凪) preset only needs KawaPress:

Shell
npm install --save-dev kawapress

KawaPress is only required while developing and building the site. The deployed output does not require a Node.js server.

Add Project Scripts #

Add these commands to the scripts field in package.json:

JSON
{
  "scripts": {
    "docs:dev": "kawapress dev",
    "docs:build": "kawapress build",
    "docs:preview": "kawapress preview"
  }
}
  • docs:dev starts the development server.
  • docs:build generates the static site.
  • docs:preview serves the production build locally.

Configure the Site #

Create kawapress.config.ts in the project root:

TypeScript
import { nagi } from 'kawapress/nagi'

export default nagi({
  title: 'My Docs',
})

The nagi() preset installs the default documentation interface and its plugins. Its styles are included automatically, so the site does not need a separate theme CSS import.

Add Head Tags #

Use head to put tags into the <head> of every page. Analytics scripts, Open Graph cards for sharing, and site verification tags all go here:

TypeScript
import { nagi } from 'kawapress/nagi'

export default nagi({
  head: [
    ['script', { src: 'https://example.com/analytics.js', defer: true }],
    ['meta', { property: 'og:image', content: 'https://example.com/social.png' }],
  ],
})

Each entry is [tag, attributes, content?]. The tag name must be meta, link, script, style, or noscript. Attribute values are strings or true/false. The optional third element is the raw content inside the tag, which suits inline scripts and styles. KawaPress owns title and base, so they are not accepted here. Addresses are used as written, so include the site base yourself on internal paths.

Multi-language sites can give each language its own head. Tags with the same name or property follow the language setting:

TypeScript
import { nagi } from 'kawapress/nagi'

export default nagi({
  locales: {
    root: {
      label: 'English',
      lang: 'en',
      head: [['meta', { property: 'og:locale', content: 'en_US' }]],
    },
    zh: {
      label: '简体中文',
      lang: 'zh-CN',
      head: [['meta', { property: 'og:locale', content: 'zh_CN' }]],
    },
  },
})

A single page can add tags of its own in frontmatter. See Frontmatter.

Use UnoCSS Utilities #

nagi enables UnoCSS with presetWind4, presetIcons, and presetWebFonts. Wind4 utilities work directly in Markdown HTML:

UnoCSS generates this card's spacing, radius, and translucent background.
HTML
<div class="rounded-xl bg-indigo-500/8 px-4 py-3 text-sm">
  UnoCSS generates this card's spacing, radius, and translucent background.
</div>

The Wind4 global reset is disabled, so it does not overwrite nagi or other plugin foundations. The Icons and Web Fonts presets are ready, but they load assets only after you configure a specific icon collection or font.

Add Your First Pages #

Create index.md in the project root:

Markdown
---
layout: home
title: My Docs
---

# My Docs

Welcome to my first KawaPress site.

[Start reading](/guide/hello)

Then create guide/hello.md:

Markdown
# Hello, KawaPress!

This is my first documentation page.

The project should now contain:

Text
my-kawapress-site/
├─ guide/
│  └─ hello.md
├─ index.md
├─ kawapress.config.ts
└─ package.json

Markdown file paths become public routes:

  • index.md maps to /.
  • guide/hello.md maps to /guide/hello.

The home page explicitly selects layout: home. Other Markdown pages use the doc layout by default, which includes the Sidebar and page outline.

Start the Development Server #

Run:

Shell
npm run docs:dev

The site is now available at http://localhost:5173. Open it in a browser and follow the link from the home page to the guide.

Markdown changes are applied through HMR. Initial requests still run through real server-side rendering, so development and production builds share the same SSR semantics.

Build and Preview #

Generate the static site:

Shell
npm run docs:build

KawaPress writes the deployable output to dist. Preview that output locally with:

Shell
npm run docs:preview

The preview server runs at http://localhost:4173 by default. After checking the result, deploy the dist directory to any static hosting service.

You Are Ready #

You now have a complete KawaPress site that:

  • uses Markdown for pages;
  • uses nagi for its documentation interface;
  • provides HMR and real SSR during development;
  • builds static files that do not require a Node.js server.

You can keep adding Markdown pages or move on to routing, Markdown extensions, multilingual sites, plugins, and themes. Each of those features builds on the same project structure.

Comments