Getting started
Static export
When every visitor sees the same pages, oriel export saves your app's pages as plain files that any static host can
serve, with no Oriel server running.
Introduction#
A documentation site, a blog without comments, a product page: some apps answer every visitor the same way. For them,
running a server is optional. oriel export starts your app, asks it for each page the way a browser would, and writes
the answers to a folder. Upload the folder to any static host, such as Vercel, Netlify, GitHub Pages or an S3 bucket,
and the site works without a server.
The pages are still made by your app: its routes, controllers, views and middleware all run, once per page, while you export. What an export can't keep is anything that happens per request: forms that post, sessions, logins, Live components and anything else that needs the server to answer.
Exporting your app#
Build the assets first, then export:
npm run buildnode oriel exportThe site is written to dist/. The command lists the redirects it met and how many pages it wrote:
Redirect /old → /about, not written.Exported 24 pages to [dist] in 840 ms.--output writes somewhere else:
node oriel export --output=siteThe export only replaces a folder it made itself (or an empty one), so pointing --output at a folder that holds
other files stops it without deleting anything. It also stops while the Vite dev server runs (public/ exists),
since the pages would point at the dev server: stop npm run dev, build, then export.
Which pages are exported#
The export starts at / and follows every link to the same site, using the origin of app.url. A link to another
site, a mailto: or tel: link, or a link to a file in public/ is left alone. Query strings and #anchors are
ignored, so /docs/ exports /docs/.
Pages nothing links to, such as a feed, are listed in paths. Pages to leave out are listed in exclude, where *
matches anything. A redirect is listed in the command's output and not written; the page it points at is exported, even when nothing else
links to it.
A page that answers with an error (4xx or 5xx) stops the export and names the page. The site is written into a temporary folder first, so the last export stays as it was.
Configuration#
Add a config/ file to change the defaults:
export default { output: 'dist', crawl: true, paths: ['/feed.xml'], exclude: ['/drafts/*'], file_names: 'html',}| Key | Default | |
|---|---|---|
output | 'dist' | The folder the site is written to, relative to the app |
crawl | true | Follow links from / and from paths; false exports only those |
paths | [] | Pages to export besides / |
exclude | [] | Pages to leave out; * matches anything |
file_names | 'html' | 'html' writes /docs/ as docs/; 'directory' writes docs/ |
A path with an extension, such as /feed.xml, keeps its name in either style. The files in public/, your built
assets among them, are copied into the folder first.
The 404 page#
The export writes your app's 404 page as 404.html: yours (resources/), or Oriel's own when you
have none. Vercel, Netlify and GitHub Pages show that file for an address that doesn't exist.
Hosting the files#
- Vercel and Netlify serve
docs/atrouting.html /docs/when clean URLs are on (Vercel'srouting cleanUrls, Netlify's pretty URLs). - GitHub Pages and most other hosts serve
docs/atrouting.html /docs/, androuting.html docs/atrouting/ index.html /docs/: export withrouting/ file_names: 'directory'for addresses without.html.
To run your app live instead, with forms, sessions and Live components, see Deployment.