Github Pages
Deploy a statically generated SvelDocs site to GitHub Pages.
Configure GitHub Pages
SvelDocs includes a workflow that validates, builds, and deploys the site whenever you push to the main branch.
In your GitHub repository, open Settings > Pages and set Source to GitHub Actions. The next push to main will run the deployment workflow.
GitHub Pages hosts static output. Keep the default static adapter configuration described in Static Site Generation.
Deployment Workflow
The workflow performs four tasks:
- Installs dependencies with Bun
- Runs the tests, Svelte checks, and linting
- Builds the site with a repository-specific base path
- Uploads and deploys the generated
builddirectory
name: Deploy to GitHub Pages
on:
push:
branches: 'main'
jobs:
build_site:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Validate
run: bun test && bun run check && bun run lint
- name: Build
env:
BASE_PATH: '/${{ github.event.repository.name }}'
run: bun run build
- name: Upload Artifacts
uses: actions/upload-pages-artifact@v3
with:
path: 'build/'
deploy:
needs: build_site
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4 The BASE_PATH value is set to the repository name so project sites work at URLs such as https://your-username.github.io/your-repository.
If you deploy at the root of a custom domain or an organization site, update or remove BASE_PATH to match that URL structure.
You can remove this workflow if you deploy to a different host. See Template Updates before customizing it, because workflow files are not changed by automated template update pull requests.