Skip to content

GitHub Pages

Both are the static output under another name. Nothing here runs a server, so useDraftMode, server routes and the other things static drops are dropped the same way.

Reference

Presetgithub-pages
Runs onGitHub Pages
event.runtime.namestatic
Server targetbun
Lifetime, startupprocess, load

Output

text
.output/
  hamur.json
  public/                    the prerendered pages
    .nojekyll
    404.html

Config keys

This preset has no key of its own; app.baseURL matters for a project site.

Detection

The build selects it when GITHUB_PAGES and GITHUB_ACTIONS are both set; GITHUB_ACTIONS alone selects nothing, because every GitHub Actions job sets it.

Deploy command

No hamur deploy command: it exits 1 for this preset. Upload .output/public/ with actions/upload-pages-artifact and publish it with actions/deploy-pages.

Limits

  • Does not run: WebSockets and server.syncedState, server.pubsub, streamed answers, server.metrics, image transforms at run time, private app/env.ts entries read at run time, Durable Object classes.
  • It is the static output: server routes, proxy, cors, swr and cache rules and server.fallbackProxy are dropped with a warning.

The levels are the features of the preset: hamur build warns or fails when the app uses a feature the preset does not run (see Preset features).

--preset github-pages (with hamur generate --preset github-pages) writes .output/public/ with the prerendered pages, 404.html and an empty .nojekyll. It is chosen when both GITHUB_PAGES and GITHUB_ACTIONS are set, or by name; GITHUB_ACTIONS alone selects nothing, because every GitHub Actions job sets it.

  • .nojekyll turns off the Jekyll build that GitHub Pages runs on a published branch or folder; Jekyll drops files and directories whose names start with an underscore, which would remove _hamur/ and every script and style with it. GitHub's publishing source page says an external CI build that commits to a branch "typically include[s] a .nojekyll file".
  • 404.html is what GitHub Pages answers for a path that matches no file; it sits at the root of the published folder.
  • A project site is served under /<repository>/. With app.baseURL unset and GITHUB_REPOSITORY=owner/repo, the build logs app.baseURL is "/"; a project site is served under "/repo/" and changes nothing; set the base yourself:
ts
export default defineConfig({ app: { baseURL: "/repo/" } })

Upload .output/public/ with actions/upload-pages-artifact and publish it with actions/deploy-pages.