Page Generation
The page keyword generates complete HTML files from a declarative element tree. Elements are automatically classified into <head> and <body>.
Basic Page
page "index.html":
title "My App"
h1 "Hello World"
p "Welcome to my site"
This generates a full HTML5 document with proper <!DOCTYPE>, <meta charset>, and viewport tags.
Nested Elements
Use indentation to nest elements. The first argument can be a #id, a .class, or a class name:
page "app.html":
title "Dashboard"
style "styles.css"
div "container":
h1 "Dashboard"
div "cards":
div "card":
h3 "Users"
p "1,234"
div "card":
h3 "Revenue"
p "$5,678"
module "build/client.mjs"
Keep browser behavior in a .naide client module; the generated browser module is build output.
Forms and Attributes
Place standard attributes on child lines. Use attr for aria-* and data-* attribute names. Values are escaped as HTML, and event-handler attributes are not accepted:
page "index.html":
title "Sign up"
main "#app":
form "#signup":
action "/signup"
method "post"
label "Email address":
attr "for" "email"
input:
id "email"
type "email"
name "email"
autocomplete "email"
required
attr "aria-label" "Email address"
button "#submit" "Create account":
type "submit"
Run a Web Project
Create a NAIDE-first website and start the local development server with automatic rebuild and browser refresh:
naide init my-site --template web
cd my-site
naide dev .
The starter keeps behavior in .naide, styles in CSS, and project metadata in nidpackage.json. Generated modules are build output, not authored source.
Head vs Body Elements
Elements are automatically placed in the correct section:
| Element | Placement | Output |
|---|---|---|
title "text" |
<head> | <title>text</title> |
style "file.css" |
<head> | <link rel="stylesheet" href="file.css"> |
meta "name" "content" |
<head> | <meta name="name" content="content"> |
module "build/client.mjs" |
<body> | <script type="module" src="build/client.mjs"></script> |
img "src" "alt" |
<body> | <img src="src" alt="alt"> |
a "url" "text" |
<body> | <a href="url">text</a> |
input "type" "name" |
<body> | <input type="type" name="name" placeholder="name"> |
Any other tag (h1, h2, p, div, span, form, etc.) goes to <body>.
Multi-Target
| Target | Output |
|---|---|
| Node.js | fs.writeFileSync() |
| Bun | Bun.write() |
| Python | open().write() |