Prerequisites
Before deploying, make sure your site builds locally with hugo without errors.
Deploy to GitHub Pages
GitHub Pages builds your site using GitHub Actions. The workflow installs Hugo, runs Pagefind, and publishes the result. Your repository must be hosted on GitHub.
In your repository, go to Settings > Pages.
Under Build and deployment, set the source to GitHub Actions.
Create
.github/workflows/deploy.yml. The workflow has two jobs:buildchecks out the repo, installs Hugo and Node dependencies, builds the site, runs Pagefind, and uploads the output as an artifact.deploythen publishes that artifact to GitHub Pages..github/workflows/deploy.ymlname: Deploy 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: - name: Checkout uses: actions/checkout@v6 with: submodules: recursive fetch-depth: 0 # Optional, for enableGitInfo - name: Install Hugo uses: peaceiris/actions-hugo@v3 with: hugo-version: '0.161.0' extended: true - name: Setup Pages id: pages uses: actions/configure-pages@v6 - name: Setup NodeJS uses: actions/setup-node@v6 with: node-version: '22' - name: Install dependencies run: npm install - name: Build site run: hugo --gc --minify --baseURL "${{ steps.pages.outputs.base_url }}" - name: Index with Pagefind run: npm run pagefind - uses: actions/upload-pages-artifact@v3 with: path: public deploy: needs: build runs-on: ubuntu-latest environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - id: deployment uses: actions/deploy-pages@v4Commit and push the file. GitHub Actions will trigger automatically.
Deploy to Other Hosting Services
See Hugo's official tutorial. Add npm run pagefind to your build step to generate the search index.