Deployment & Base Path

Luma Docs is optimized for GitHub Pages and any static host. The key differentiator is an intelligent base path resolver that eliminates fragile manual tweaks.

Base Path Scenarios

Repository TypeURL PatternBase Path Result
User/Org Pages repo (username/username.github.io)https://username.github.io//
Project Pages repo (username/repo)https://username.github.io/repo//repo/
Custom Domain (CNAME)https://docs.example.com//
Forced Preview (VITE_FORCE_BASE=/preview/)Any/preview/

The resolver checks (in order):

  1. VITE_FORCE_BASE
  2. SITE_URL (exported by CI step if present)
  3. GITHUB_REPOSITORY (owner/name)
  4. Git remote origin URL (parses repo name)

Local Development in a Subfolder

Simulate a project pages deployment locally:

VITE_FORCE_BASE=/my-repo/ npm run dev

Links, assets, and search still work transparently.

CI Workflow (Native Pages)

The recommended workflow (excerpt):

permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  build:
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci --prefer-offline --no-audit
      - run: npm run build
        env:
          GITHUB_REPOSITORY: ${{ github.repository }}
      - uses: actions/upload-pages-artifact@v3
        with:
          path: ./dist
  deploy:
    needs: build
    steps:
      - uses: actions/deploy-pages@v4

No need to manually set a homepage field or hard-code paths.

Custom Domains

  1. Add a CNAME file at repo root with your domain.
  2. Configure DNS (CNAME record → username.github.io).
  3. GitHub Pages automatically provisions SSL.
  4. Resolver sees CNAME in CI step and keeps base path /.

Asset Integrity

Because the base path is injected before Vite builds, all emitted asset URLs (CSS, JS, images) are correct for both root and subfolder hosting.

Troubleshooting

IssueCauseFix
404 on refresh in subfolderMissing trailing slash normalization in host configEnsure GitHub Pages; other hosts may need 404.html fallback
Double slashes in URLsManual concatenation in custom componentUse basePath helper from @/utils/basePath
Wrong base after forkFork remote not yet fetchedRun git fetch --all or set VITE_FORCE_BASE explicitly

Forcing a Preview Environment

Useful for staging docs at https://username.github.io/repo-pr-123/:

VITE_FORCE_BASE=/repo-pr-123/ npm run build

Upload dist/ to that path on any static host (Cloudflare Pages, Netlify, S3) and everything functions identically.

Extending Deployment

GoalStrategy
Add link checkerNew CI step after build using lychee
Add performance budgetLighthouse CI in separate job (uses built dist/)
Add broken anchor detectionParse generated-search-index + HTML fragment IDs

The deployment story aims for zero surprises — one build command, any static host, correct paths.