# GitLab Pages

`--preset gitlab-pages` writes the same `.output/public/` (without `.nojekyll`). It has no detection: `GITLAB_CI` is set in every GitLab CI job, so it would turn any build there into a static one. GitLab Pages [publishes a directory named `public`](https://docs.gitlab.com/ci/yaml/#pages) by default (`pages: true`), or the one `pages.publish` names, and needs a non-empty `index.html` at its root. Either point `pages.publish` at `.output/public`, or let Hamur write `public/`:

## Reference

|                      |                   |
| -------------------- | ----------------- |
| Preset               | `gitlab-pages`    |
| Runs on              | GitLab Pages      |
| `event.runtime.name` | `static`          |
| Server target        | `bun`             |
| Lifetime, startup    | `process`, `load` |

### Output

```text
.output/
  hamur.json
  public/                    the prerendered pages and 404.html (no .nojekyll)
public/                      a copy of the above, only with gitlabPages.publicDir
```

### Config keys

| Key                     | Default | What it does                                                                                        |
| ----------------------- | ------- | --------------------------------------------------------------------------------------------------- |
| `gitlabPages.publicDir` | `false` | `true` also copies the output to `public/` at the app root, where GitLab Pages publishes by default |

### Detection

None. Name it with `--preset`, `preset` in the config or `HAMUR_PRESET`; no environment variable selects it.

### Deploy command

No `hamur deploy` command: it exits 1 for this preset. Point `pages.publish` at `.output/public`, or set `gitlabPages.publicDir`.

### 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](/deploy#preset-features)).

```ts
export default defineConfig({ preset: "gitlab-pages", publicDir: "static", gitlabPages: { publicDir: true } })
```

With `gitlabPages.publicDir: true` the build copies `.output/public/` to `public/` at the app root and puts a `.hamur-output` file in it. The next build replaces that folder; a `public/` without the file is never touched and the build fails naming it. Hamur's own `publicDir` defaults to `public/`, which is the same folder, so set `publicDir` to another folder first or the build fails (`gitlabPages.publicDir would overwrite the app's public/; set publicDir in hamur.config.ts to another folder`).
