Deployment
Build and deploy to GitHub Pages.
On this page
npm Scripts
| Script | Purpose |
|---|---|
npm run dev |
Development server with hot reload |
npm run build |
Production build (minified CSS) |
npm run clean |
Remove dist/ directory |
GitHub Pages
Create .github/workflows/deploy.yml:
name: Deploy to GitHub Pages
on:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- run: npm ci
- run: npm run build
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: "./dist"
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: github-pages
url: $
steps:
- uses: actions/deploy-pages@v4
id: deployment
Path Prefix
For project sites (username.github.io/repo-name), set path prefix in eleventy.config.js:
return {
pathPrefix: process.env.GITHUB_ACTIONS ? "/repo-name/" : "/",
};
Custom Domain
- Add a
CNAMEfile tosrc/with your domain - Add passthrough copy:
eleventyConfig.addPassthroughCopy("src/CNAME") - Configure DNS to point to GitHub Pages
Build Verification
Before deploying, verify locally:
# Clean build
npm run clean && npm run build
# Serve the dist folder
npx serve dist
Maintenance
Guidance for keeping your site up to date.
Updating Dependencies
Check for outdated packages:
npm outdated
Update to latest compatible versions:
npm update
For major version upgrades, update package.json manually and test thoroughly. Pay special attention to:
- Eleventy — Check the release blog for breaking changes
- Tailwind CSS — Review the upgrade guide for migration steps
- Stimulus — Generally backwards compatible; check release notes
Content Updates
Content lives in src/. Common tasks:
| Task | Where |
|---|---|
| Edit page content | src/*.njk or src/**/*.md |
| Update site metadata | src/_data/site.json |
| Change navigation | src/_data/sections.json |
| Modify layouts | src/_includes/layouts/ |
| Update partials | src/_includes/partials/ |
| Adjust styling | src/assets/css/main.css |
Adding Pages
- Create a new
.njkor.mdfile insrc/ - Add frontmatter with layout, title, and description
- Add to
sections.jsonif it should appear in navigation - Update prev/next links on adjacent pages if using chapter navigation
Adding Controllers
- Create
src/assets/js/controllers/your_controller.js - Register in
application.js:import YourController from "./controllers/your_controller.js"; application.register("your", YourController); - Use in templates:
data-controller="your"
Troubleshooting
| Issue | Solution |
|---|---|
| CSS not updating | Run npm run clean and rebuild |
| Search not finding content | Rebuild to regenerate Pagefind index |
| Build fails | Check for Nunjucks syntax errors in templates |
| Controller not working | Verify registration in application.js |
| Styles missing in production | Ensure classes are in @source paths in main.css |