Building a website with Zola and Github Pages
Learn how to build and deploy a static website using Zola and GitHub Pages. Building a static website is easier than ever with tools like Zola and GitHub Pages. In this post, I'll walk you through the process of creating your own site and publishing it for free. First, install Zola using Cargo: Verify the installation: Generate a new site: Follow the prompts to set up your site. To preview locally: Visit To build the static files: The output will be in the Initialize a git repository and push your code: You can use GitHub Actions to automatically deploy your site. Add a workflow file at Commit and push this file. With Zola and GitHub Pages, you can quickly build and deploy a fast, modern static website. Happy building!Prerequisites
1. Install Zola
cargo install zola
zola --version
2. Create a New Zola Site
zola init mysite
cd mysite
3. Add Content and Customize
config.toml
to set your site title and other settings.content/
directory.4. Build the Site
zola serve
http://127.0.0.1:1111
in your browser.zola build
public/
directory.5. Push to GitHub
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/yourusername/your-repo.git
git push -u origin main
6. Deploy with GitHub Pages
.github/workflows/deploy.yml
:name: Deploy Zola site to GitHub Pages
on:
push:
branches:
- main
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Zola
run: cargo install zola
- name: Build site
run: zola build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
7. Configure GitHub Pages
gh-pages
branch (created by the workflow).https://yourusername.github.io/your-repo/
.Conclusion