Skip to content

Commit ae9a610

Browse files
authored
docs: add GitHub Pages deployment 🐺 (#7885)
1 parent 2d29e6e commit ae9a610

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed

e2e/docs-e2e/tests/Docs/deployments-pages-load.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,8 @@ test('Deployments Static Site Adapter page loads', async ({ page }) => {
6565
await page.goto('/docs/deployments/static/');
6666
await expect(page).toHaveTitle('Static Site 📚 Qwik Documentation');
6767
});
68+
69+
test('Deployments GitHub Pages Adapter page loads', async ({ page }) => {
70+
await page.goto('/docs/deployments/github-pages/');
71+
await expect(page).toHaveTitle('GitHub Pages 📚 Qwik Documentation');
72+
});
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
title: GitHub Pages
3+
contributors:
4+
- gioboa
5+
updated_at: '2025-08-29T00:00:00Z'
6+
created_at: '2025-08-29T00:00:00Z'
7+
---
8+
9+
import PackageManagerTabs from '~/components/package-manager-tabs/index.tsx';
10+
11+
# GitHub Pages With Static Site Adapter
12+
13+
Qwik's Static Site adapter helps to generate static html files which can be easily deployed to GitHub Pages.
14+
15+
## Installation
16+
17+
To integrate the `static-site` adapter, use the `add` command:
18+
19+
<PackageManagerTabs>
20+
<span q:slot="pnpm">
21+
```shell
22+
pnpm run qwik add static
23+
```
24+
</span>
25+
<span q:slot="npm">
26+
```shell
27+
npm run qwik add static
28+
```
29+
</span>
30+
<span q:slot="yarn">
31+
```shell
32+
yarn run qwik add static
33+
```
34+
</span>
35+
<span q:slot="bun">
36+
```shell
37+
bun run qwik add static
38+
```
39+
</span>
40+
</PackageManagerTabs>
41+
42+
Above command will create a directory at project root named `adapters/static/vite.config.ts` with the below code.
43+
44+
```ts title="adapters/static/vite.config.ts"
45+
import { staticAdapter } from "@builder.io/qwik-city/adapters/static/vite";
46+
import { extendConfig } from '@builder.io/qwik-city/vite';
47+
import baseConfig from '../../vite.config';
48+
49+
export default extendConfig(baseConfig, () => {
50+
return {
51+
build: {
52+
ssr: true,
53+
rollupOptions: {
54+
input: ['@qwik-city-plan'],
55+
},
56+
},
57+
plugins: [
58+
staticAdapter({
59+
origin: 'https://yoursite.qwik.dev',
60+
}),
61+
],
62+
};
63+
});
64+
```
65+
66+
> Remember to change the `origin` in this file to your domain.
67+
68+
In the main `vite.config.ts` you should add the base property and set the value with the name of your repository.
69+
70+
```ts
71+
export default defineConfig(({ command, mode }): UserConfig => {
72+
return {
73+
base: '/github-repository-name/',
74+
[...]
75+
}
76+
});
77+
```
78+
79+
## Automated Deployment to GitHub Pages with GitHub Actions
80+
81+
GitHub Actions enables automated deployment of your site to GitHub Pages upon code changes.<br/>
82+
To enable this feature, configure your repository settings as follows:
83+
- Navigate to GitHub Pages Settings: Access your repository's GitHub Pages settings by visiting the /settings/pages path within your repository.<br/>
84+
For example: https://github.com/your-github-username/github-repository/settings/pages.
85+
- Configure Deployment Source: Under the "Source" section, select "GitHub Actions" as the deployment source.<br/>
86+
This instructs GitHub Pages to use a GitHub Actions workflow for deployments.
87+
88+
## Add The GitHub Action
89+
90+
Here's an example:
91+
92+
```yml
93+
# FILE: .github/workflows/deploy.yml
94+
# ==========================================
95+
96+
name: Deploy to GitHub Pages
97+
98+
on:
99+
push:
100+
branches: 'main'
101+
102+
jobs:
103+
build_site:
104+
runs-on: ubuntu-latest
105+
steps:
106+
- name: Checkout
107+
uses: actions/checkout@v4
108+
109+
- name: Install pnpm
110+
uses: pnpm/action-setup@v3
111+
with:
112+
version: 10.15.0
113+
114+
- name: Install Node.js
115+
uses: actions/setup-node@v4
116+
with:
117+
node-version: 24.7.0
118+
cache: 'pnpm'
119+
120+
- run: corepack enable
121+
122+
- name: Install dependencies
123+
run: pnpm install --frozen-lockfile
124+
125+
- name: build
126+
run: |
127+
pnpm run build
128+
129+
- name: Upload Artifacts
130+
uses: actions/upload-pages-artifact@v3
131+
with:
132+
path: 'dist/github-repository-name/'
133+
134+
deploy:
135+
needs: build_site
136+
runs-on: ubuntu-latest
137+
138+
permissions:
139+
pages: write
140+
id-token: write
141+
142+
environment:
143+
name: github-pages
144+
url: ${{ steps.deployment.outputs.page_url }}
145+
146+
steps:
147+
- name: Deploy
148+
id: deployment
149+
uses: actions/deploy-pages@v4
150+
```
151+
152+
This GitHub Actions workflow automates the process of building and deploying a website to GitHub Pages.<br/>
153+
It triggers upon pushes to the main branch, ensuring the site is updated with the latest changes.<br/>
154+
The workflow first builds the website using pnpm, then uploads the generated files as an artifact.<br/>
155+
Finally, it deploys the artifact to GitHub Pages, making the site live.

packages/docs/src/routes/docs/menu.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
- [Self-Hosting](deployments/self-hosting/index.mdx)
103103
- [Vercel Edge](deployments/vercel-edge/index.mdx)
104104
- [Static Site](deployments/static/index.mdx)
105+
- [GitHub Pages](deployments/github-pages/index.mdx)
105106
- [Azion](deployments/azion/index.mdx)
106107

107108
## Guides

0 commit comments

Comments
 (0)