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

The AI Hype Is Hitting a Wall Now

November 12, 2025

I’ve been hearing the narrative for two years. Everyone thinks AI is coming for all the jobs, starting with programming. But I am a developer, and from where I stand, the hype is settling down. …

Don't Call AI "The Future" Until You Know This

November 12, 2025

The market is currently overflowing with hype about Artificial Intelligence. You hear it everywhere: AI is the new revolution, the new internet, the new electricity. Alongside this hype, there’s …

Why I Chose Cloudflare Pages Over a VPS: The Best "True Free Host" for Static Sites

November 10, 2025

As a web developer who has built everything from small portfolios to complex agency sites, I’ve spent years navigating the hosting landscape. The debate between traditional hosting and modern …

Next.js Deployments: Vercel vs Cloudflare Stack (OpenNext, Workers, R2, D1)

November 9, 2025

Next.js Deployment: Vercel’s Walled Garden vs. The Cloudflare Superstack As a developer, I love Next.js. It’s a powerhouse. And naturally, the “easy button” for deployment is …

How I Optimized Core Web Vitals to 100% on My HugoGo Website

October 31, 2025

Optimizing a HugoGo website to achieve a perfect 100% Core Web Vitals score is completely possible without major code rewrites. Hugo’s static site generation already gives a strong base — with server …

Best Nodejs Package Hicons for HugoGo: Effortless SVG Icon Management

October 31, 2025

SVG icons are a staple of modern web design, but managing them in static site generators like Hugo can be tedious. If you’ve ever found yourself manually copying SVG code, worrying about layout bloat, …