Skip to content

Set up GitHub Pages deployment with static export - #1

Merged
zagdrath merged 2 commits into
mainfrom
claude/nextjs-github-pages-workflow-n2pumu
Jul 26, 2026
Merged

Set up GitHub Pages deployment with static export#1
zagdrath merged 2 commits into
mainfrom
claude/nextjs-github-pages-workflow-n2pumu

Conversation

@zagdrath

Copy link
Copy Markdown
Member

This PR configures the project for deployment to GitHub Pages as a static site.

Summary

The project is now configured to build as a static export and deploy to GitHub Pages via a new CI/CD workflow. This includes updating the Next.js configuration, adding a GitHub Actions workflow, and adjusting image imports to work correctly with the base path prefix used for project sites.

Key Changes

  • Added GitHub Actions workflow (.github/workflows/deploy.yml): Builds on every push and deploys the main branch to GitHub Pages. The workflow handles Pages enablement, builds the static export, runs linting, and deploys the artifact.

  • Updated Next.js configuration (next.config.ts):

    • Set output: "export" for static generation
    • Added basePath and assetPrefix configuration that reads from NEXT_PUBLIC_BASE_PATH environment variable (set by the workflow for project sites, empty for local builds and custom domains)
    • Enabled trailingSlash for proper static routing
    • Disabled Next.js image optimization (unoptimized: true) since GitHub Pages is a static host
  • Updated image imports in three components (site-nav.tsx, site-footer.tsx, products.tsx): Changed from URL-based references (src="/assets/...") to ES module imports so that asset URLs are rewritten by the bundler to include the base path prefix. This prevents 404s when the site is served from a subdirectory.

  • Updated README with deployment documentation explaining the static export setup, base path handling, and one-time repository configuration needed.

Implementation Details

The base path approach allows the same build to work both as a project site (served from /<repo>) and behind a custom domain (served from /). The configure-pages action automatically derives the correct base path from the repository's Pages configuration, eliminating the need for manual config changes when switching between deployment modes.

https://claude.ai/code/session_01CKwW1rRwjbAA2CZZh6tWh8

Add a workflow that builds on every push and deploys main to Pages via
the Actions artifact flow.

Pages is a static host, so switch Next.js to `output: "export"` with
image optimization off. A project site lives under /<repo>, so the build
passes that prefix to basePath/assetPrefix as NEXT_PUBLIC_BASE_PATH; the
value is empty locally, and committing a domain to public/CNAME switches
it to the root for a custom domain.

basePath is not applied to `next/image` sources when images are
unoptimized, so import the three image assets instead of referencing
them as root-relative URLs — the bundler emits those with the prefix.

The build deliberately does not call actions/configure-pages: GITHUB_TOKEN
cannot create the Pages site on this org, and a failure there would break
the build on every branch rather than just the deploy. Pages has to be
pointed at GitHub Actions once by hand.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CKwW1rRwjbAA2CZZh6tWh8
@zagdrath
zagdrath force-pushed the claude/nextjs-github-pages-workflow-n2pumu branch from cb3e003 to 214e2ca Compare July 26, 2026 01:14
Add public/CNAME so each deploy asserts the custom domain on Pages. The
workflow already keys the base path off that file, so the build switches
from the /quartz-systems-website project path to the root.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CKwW1rRwjbAA2CZZh6tWh8
@zagdrath
zagdrath merged commit 0d9dcb8 into main Jul 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant