Skip to main content
independoc
Language: English

Deploy to GitHub Pages & Static Hosts#

independoc build outputs pure static files (HTML / CSS / JS / JSON / XML / TXT) into dist/. No server-side Node.js runtime is needed — deploy directly to any static host.

Automatic Deployment to GitHub Pages#

This repository includes a GitHub Pages workflow (.github/workflows/pages.yml) that runs without npm install.

1. One-Time Repository Setup#

  1. Open Settings → Pages in your GitHub repository.
  2. Under Build and deployment → Source, select GitHub Actions.
  3. If you changed Source after merging the workflow, trigger the initial deployment manually from Actions → Deploy Docs to GitHub Pages → Run workflow (subsequent pushes to main deploy automatically).

2. How the Workflow Works (.github/workflows/pages.yml)#

Passing actions/configure-pages's base_path output to --base and its origin output to --site-url keeps canonical, sitemap, and llms.txt absolute URLs aligned with project pages (https://<user>.github.io/<repo>/) and custom domains alike. Setting fetch-depth: 0 enables accurate per-file Git timestamps when showLastUpdated: true is enabled.

.github/workflows/pages.yml
name: Deploy Docs to GitHub Pages

on:
  push:
    branches: [main]
  workflow_dispatch:

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

concurrency:
  group: pages
  cancel-in-progress: false

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v7
        with:
          node-version: 22
      - run: npm test
      - id: pages
        uses: actions/configure-pages@v6
      - name: Build static docs
        env:
          PAGES_BASE_PATH: ${{ steps.pages.outputs.base_path }}
          PAGES_ORIGIN: ${{ steps.pages.outputs.origin }}
        run: |
          BASE_PATH="${PAGES_BASE_PATH:-/}"
          SITE_URL_ARGS=()
          if [ -n "${PAGES_ORIGIN}" ]; then
            SITE_URL_ARGS+=(--site-url "${PAGES_ORIGIN}")
          fi
          node ./bin/independoc.js build --base "${BASE_PATH}" "${SITE_URL_ARGS[@]}" --strict-links
      - uses: actions/upload-pages-artifact@v5
        with:
          path: dist

  deploy:
    needs: build
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - id: deployment
        uses: actions/deploy-pages@v5

Other Static Hosts#

When canonical, sitemap, or llms.txt absolute URLs must match the public host, pass the deployment origin at build time, for example --site-url https://docs.example.com.

  • Build command: node ./bin/independoc.js build --strict-links
  • Output directory: dist
  • Node.js version: 22 or newer (no install command needed)

Serve dist/ directly from your document root or sub-path. Because every route maps to <route>/index.html, no SPA rewrite rules are needed. On Amazon S3, enable Static Website Hosting with index.html as the index document and use the website endpoint.

bash
# Example: host under /docs/ on an internal portal
node ./bin/independoc.js build --base /docs/ --strict-links
Edit this pageLast updated:
Built with independoc itself — 0 npm dependencies.