This guide shows you how to automatically deploy your Genereto-generated site to GitHub Pages using GitHub Actions.
content/
directoryCreate .github/workflows/docs.yml
in your repository:
name: Deploy Documentation
on:
push:
branches: [ "main" ]
paths:
- 'docs/**'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build site with Genereto
id: build
uses: FedericoPonzi/genereto/.github/actions/build-site@v1.0.0-ga
with:
project-path: './docs'
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ steps.build.outputs.output-path }}
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Organize your project like this:
your-repo/
├── .github/workflows/docs.yml
├── docs/
│ ├── config.yml
│ ├── content/
│ │ ├── index.md
│ │ └── blog/
│ └── templates/main/
│ ├── index.html
│ └── blog.html
├── src/
└── Cargo.toml
Update your docs/config.yml
:
template: main
title: Your Site Title
url: https://yourusername.github.io/your-repo
description: Your site description
default_cover_image: ../assets/logo.jpg
blog:
base_template: blog.html
index_name: index.html
destination: blog/
generate_single_pages: true
Push your changes to the main branch. The workflow will:
Your site will be available at https://yourusername.github.io/your-repo
.
The new Genereto GitHub Action provides several advantages:
- name: Build site with specific version
uses: FedericoPonzi/genereto/.github/actions/build-site@v1.0.0-ga
with:
project-path: './docs'
genereto-version: 'v0.2.0'
- name: Build site with custom output
uses: FedericoPonzi/genereto/.github/actions/build-site@v1.0.0-ga
with:
project-path: './website'
output-path: 'dist'
paths
in your workflow to only trigger builds when content changesworkflow_dispatch
to manually trigger deployments