π ShadowNotes β Deploy Fuwari Blog to GitHub Pages
A quick, step-by-step guide to set up and deploy your Fuwari Astro blog on GitHub Pages.
π How GitHub Pages Works
To understand GitHub Pages, letβs imagine hosting a website on your local machine. You set up an Apache server and your site runs perfectly. But when you upload the same website to GitHub Pages, it doesnβt run automatically. Why? π€
On your local machine, the Apache server handles the website. GitHub Pages also provides a server automatically, but for more complex websites, you need a configuration file to tell GitHub how to deploy your site. This is done using a GitHub Actions workflow file like deploy.yml.
βοΈ Example deploy.yml
name: Deploy
on: push: branches: [main]
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: peaceiris/actions-gh-pages@v7 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./π‘ Simplified Explanation
Think of GitHub as a separate machine for every repository. To host and run your website on that machine, you need a deploy file (deploy.yml) to configure it properly.
-
The workflow automatically builds and publishes your site whenever you push updates to the main branch.
-
This ensures your website runs correctly on GitHub Pages without manual server setup.
β Requirements
Before starting, ensure the following are installed on your system:
nodenpmpnpmπ§ Installation
Before starting, make sure Node.js and NPM are installed on your system.
1οΈβ£ Install Node.js and NPM
Go to the official Node.js website.
- Download the LTS version (recommended for most users)
- Run the installer and follow the prompts.
This automatically installs Node.js and NPM.
Verify installation
node -v # Should show version >= 20npm -v # Should show version >= 92οΈβ£ Install PNPM Globally
PNPM is a fast and efficient Node.js package manager used by Fuwari:
npm install -g pnpmpnpm -v # Verify PNPM installationβ Now your system is ready to install dependencies and run Fuwari.
π Deploy on GitHub Pages
1οΈβ£ Create Repo
# On GitHub β New Repository β "blogs" (Public)2οΈβ£ Clone Repo
git clone https://github.com/username/blogs.gitcd blogs3οΈβ£ Install Fuwari
pnpm create fuwari@latest .cd <created dir>pnpm installpnpm devπ Open in browser: http://localhost:4321
π Customize Your Blog
src/config.tsβ Site config (site name, links, theme, etc.)src/content/spec/about.mdβ About page (edit your profile details)astro.config.mjsβ Astro settings (update site URL for GitHub Pages)public/favicon/*β Favicons (replace with your own logo)
π οΈ Useful pnpm Commands
pnpm new-post my-first-post # create new postpnpm build && pnpm preview # build for productionpnpm dev # run dev server4οΈβ£ Update Astro Config
astro.config.mjs
import { defineConfig } from 'astro/config';import tailwind from '@astrojs/tailwind';
export default defineConfig({ site: 'https://username.github.io/blogs', // GitHub Pages URL base: '/blogs/', // repo name integrations: [tailwind()],});5οΈβ£ GitHub Actions Workflow
Create .github/workflows/deploy.yml
name: Deploy Astro Blog to GitHub Pages
on: push: branches: [ main ] workflow_dispatch:
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 - uses: pnpm/action-setup@v2 with: version: 9 - run: pnpm install - run: pnpm build - uses: actions/upload-artifact@v4 with: name: github-pages path: ./dist
deploy: needs: build runs-on: ubuntu-latest environment: name: github-pages url: ${{ steps.deploy.outputs.page_url }} steps: - uses: actions/download-artifact@v4 with: name: github-pages path: ./dist - id: deploy uses: actions/deploy-pages@v4 with: artifact_name: github-pagesπ Note
The workflow file deploy.yml is the key configuration that sets up and builds the environment for your GitHub Pages site.
- You can think of it like a Dockerfile: it automates the environment setup, ensuring your site runs smoothly without manual intervention.
6οΈβ£ Build and Test Locally
pnpm build && pnpm preview7οΈβ£ Push to GitHub
git initgit add .git commit -m "Setup Fuwari Blog with GitHub Pages"git checkout -b maingit remote add origin https://github.com/username/notes.gitgit push origin main8οΈβ£ Enable GitHub Pages
- Go to your repository β Settings β Pages.
- Under Build and Deployment, select:
- Source β GitHub Actions
- Click Save β
π Result
Your blog is live at:
Summary
- Installed Node.js, NPM, and PNPM to set up the environment for Fuwari Astro blog
- Created and cloned a GitHub repository for deployment
- Installed Fuwari, configured site settings, and customized content (config.ts, about.md, favicons)
- Built and ran the blog locally using
pnpm devandpnpm build - Configured GitHub Actions workflow to automate deployment to GitHub Pages
- Pushed changes to GitHub and enabled GitHub Pages to publish the blog online