GitHub Pages
Deploy your documentation to GitHub Pages with automated builds.
GitHub Actions Workflow
Create .github/workflows/docs.yml:
.github/workflows/docs.yml
name: Deploy Docs
on:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
- name: Install Docyard
run: gem install docyard
- name: Build
run: docyard build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Enable GitHub Pages
- Go to your repository Settings
- Navigate to Pages in the sidebar
- Under Build and deployment, select GitHub Actions
Custom Domain
To use a custom domain:
- Add a
CNAMEfile todocs/public/:
-
docs
-
public
- CNAME
-
public
docs/public/CNAME
docs.example.com
- Update your base URL:
docyard.yml
build:
base: https://docs.example.com
- Configure DNS with your domain provider
Project Sites
For project sites at username.github.io/repo-name/:
docyard.yml
build:
base: https://username.github.io/repo-name
Caching
Speed up builds by caching the Ruby environment:
.github/workflows/docs.yml
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
Branch Protection
Recommended settings for production documentation:
- Go to Settings > Branches
- Add a rule for
main - Enable:
- Require pull request reviews
- Require status checks to pass
- Require branches to be up to date
Edit this page
Last updated
Was this page helpful?
Thanks for your feedback!