Deploy Your Hugo + Tailwind v4 Website to Cloudflare Pages Automatically with GitHub Actions

November 1, 2025
4 min read
Deploy Your Hugo + Tailwind v4 Website to Cloudflare Pages Automatically with GitHub Actions

This guide shows how to automatically deploy a Hugo + Tailwind CSS site to Cloudflare Pages every time you push code to your GitHub repository. It’s written for beginners — no advanced DevOps knowledge needed.


1. Why Cloudflare Pages

Cloudflare Pages is a free, fast, and globally distributed static site hosting service. Reasons it fits Hugo perfectly:

  • Edge CDN: Your site is cached worldwide by default.
  • Zero config HTTPS: Free SSL certificates automatically.
  • Continuous Deployment: Every git push can trigger an instant rebuild.
  • Fast builds: Uses Cloudflare’s global build infrastructure.
  • Free plan generous: Great for small to mid projects.

Compared to:

  • Vercel: Best for dynamic Next.js sites, but slower cold starts for static ones.
  • Netlify: Also strong, but slower free builds and smaller bandwidth limit.
  • Cloudflare Pages: Best for Hugo and JAMstack static sites — minimal setup, high speed.

2. Why Hugo

Hugo is the fastest static site generator (SSG). Written in Go, it can build hundreds of pages in seconds.

Advantages over other SSGs:

FeatureHugoAstroJekyll
Build speed⚡ Very fast (Go)Moderate (Node)Slow (Ruby)
Setup complexitySimpleModerateComplex
Plugin ecosystemLargeGrowingMature but older
Markdown performanceNativeJS renderSlower
Ideal forBlogs, docsComponents + partial hydrationSimple blogs

Conclusion: Hugo is best for blogs, docs, and content-driven sites needing speed + simplicity.


3. Why GitHub Actions

GitHub Actions automates tasks such as testing, building, and deploying. It connects directly with your repository, so every push can trigger an action — in this case, automatic deploy to Cloudflare Pages.


4. Full GitHub Actions Workflow

Create this file in your repo:

.github/workflows/deploy.yml

name: Deploy Hugo + Tailwind v4

on:
  push:
    branches:
      - main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup Hugo extended
        uses: peaceiris/actions-hugo@v3
        with:
          hugo-version: 'latest'
          extended: true

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 20

      - name: Cache Node.js modules
        uses: actions/cache@v3
        with:
          path: |
            ~/.npm
            node_modules
          key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - name: Install dependencies
        run: npm ci

      - name: Hugo build
        run: hugo --gc --minify

      - name: Deploy to Cloudflare Pages
        uses: cloudflare/pages-action@v1
        with:
          apiToken: ${{ secrets.CF_API_TOKEN }}
          accountId: ${{ secrets.CF_ACCOUNT_ID }}
          projectName: olimiah
          directory: './public'

5. Step-by-Step Setup

Step 1: Create your Hugo project

hugo new site mysite
cd mysite

Add a theme or your custom layouts.

Step 2: Install Tailwind CSS

Follow the Tailwind CSS Hugo setup guide. Ensure your package.json includes Tailwind and build scripts.

Step 3: Push to GitHub

Create a repository and push your code:

git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/<yourname>/<repo>.git
git push -u origin main

Step 4: Configure Cloudflare Pages

  1. Go to Cloudflare Dashboard → Pages → Create a Project

  2. Choose Connect to GitHub

  3. Select your repo but stop after selecting — we’ll use GitHub Actions instead of Cloudflare’s built-in deployer.

  4. Note down:

    • Account ID
    • Project name
    • API Token (with Cloudflare Pages permissions)

Step 5: Add Secrets to GitHub

Go to your GitHub repo → Settings → Secrets → Actions → New repository secret

Add:

  • CF_API_TOKEN → your Cloudflare API token
  • CF_ACCOUNT_ID → your account ID

These values are referenced in the workflow file.

Step 6: Commit and Push

Once .github/workflows/deploy.yml is committed to your repo:

git add .github/workflows/deploy.yml
git commit -m "Add deploy workflow"
git push

GitHub will automatically:

  • Build your Hugo site
  • Generate Tailwind CSS
  • Deploy to Cloudflare Pages

6. Verify Deployment

Check the Actions tab in GitHub → open your workflow run → confirm success. Then open your Cloudflare Pages project dashboard. You’ll see a new deployment linked to that Git push.


7. Summary

Workflow logic:

StepTask
1Checkout repository
2Install Hugo and Node.js
3Cache dependencies
4Build with Hugo + Tailwind
5Deploy public folder to Cloudflare Pages

Final Thoughts

  • Cloudflare Pages = fastest static hosting for global delivery.
  • Hugo = fastest static generator for Markdown content.
  • GitHub Actions = free automation for deployment.

Together they form a perfect JAMstack pipeline:

Push → Build → Deploy → Live globally in seconds.

Recent Articles

How I Fixed My CI/CD: Fast, Optimized, and Pro-Level Deploys (Hugo + Cloudflare)

January 14, 2026

We’ve all been there: you push a tiny CSS tweak, and then you sit… and wait… and watch the GitHub Actions logs spin. My Hugo site was taking nearly a minute to deploy. Not …

Deploy Hugo + Tailwind v4 to Cloudflare: Super Fast GitHub Workflow

January 13, 2026

So you want your Hugo site to fly, right? Like, blink-and-it’s-live kind of speed. I got you. We’re gonna set up a GitHub Actions workflow that takes your Hugo code (rocking Tailwind v4), builds it …

Is Tailwind CSS Dying in 2026? Why v4 Might Be the Framework's Final Masterpiece

January 13, 2026

Hope you’re doing good! Honestly, there’s some pretty wild news in the Tailwind world right now. It’s a mix of “the tech is amazing” and “the business is in trouble.” …

Why Hugo is the best Static Site Generators in 2026

January 13, 2026

Thinking about building a site in 2026? Honestly, the “shiny object syndrome” is real with all these frameworks, but Hugo is still the low-key king for anyone who wants a site that just …

Windows 11 vs. The Linux Crew: Why It’s Time to Jump Ship

January 13, 2026

If you’re tired of Windows 11 acting like that one overbearing landlord who enters your apartment without knocking, it’s time we talk about Linux. Switching OSs sounds like a massive headache, but …

Upgrading openSUSE Leap 16.0 to Kernel 6.18 (LTS) via Backports

January 12, 2026

Look, openSUSE Leap 16.0 is awesome. It’s stable, it’s enterprise-grade, and it doesn’t crash. But sometimes, “stable” feels a little too much like “driving your …