Docs menu
Getting started
IntroductionInstallationProject structureBuilding pages
RoutingPagesLayoutsStylingMarkdownContent and dataIslandsGoing live
SEO and headDeployingFormsGuides
Build a brochure siteAdvanced
Running as a serverReference
ReferenceBuilding pages
Pages
What a page file exports, and what the page tag receives.
A page is a file that default-exports a tag. Everything else is optional.
export const meta = {title: 'About', description: 'Who we are'}
export default tag AboutPage
<self>
<h1> "About"
What a page can export
| Export | What it does |
|---|---|
default |
Required. The tag that renders the page |
meta |
Title, description and other head settings. An object, or def meta {params, data, url} returning one |
load |
def load {params, url}: runs before render, can be async; its result is the page's data |
paths |
For dynamic routes: the list of params to build |
layout |
A different layout tag, or null for none. See Layouts |
post |
Handles form posts. Advanced |
What the page tag receives
| Prop | Value |
|---|---|
params |
URL params for dynamic routes, e.g. {slug: 'hello'} |
data |
Whatever load returned |
meta |
The final meta: site defaults merged with the page's own |
path |
The current URL path, e.g. /about |
form |
What post returned, when re-shown after a form post |
Declare the ones you use as fields:
export default tag PostPage
data
path = '/'
<self>
<h1> data.title
<p> "You're at {path}"
Loading data
load runs on the server, before the page renders. In the static build that means once,
at build time, so it can read files, call an API or a CMS:
export def load {params}
let res = await fetch("https://api.example.com/projects/{params.slug}")
await res.json!
export def meta {data}
{title: data.name, description: data.summary}
meta as a function gets data, so titles can come from the content.
Components
Anything else you write is plain Imba: put tags in src/components/ (or anywhere) and
import them. They render on the server and ship no JavaScript, unless they're
islands.