Namaste • Hello • Moi — I’m Biswa

Building, learning, and writing as I go.

← Back to all posts

Zero Cost Static Site: Hugo + Cloud Run

Word cloud for Zero Cost Static Site: Hugo + Cloud Run

In the age of heavy frontend frameworks and complex serverless architectures, sometimes the best solution is the simplest one. If you want a blazing fast, secure, and crucially—almost zero cost—website, combining Hugo with Google Cloud Run is a powerful strategy.

Here is how I built this blog using static generation and containerless deployment, and how you can do it too.

Why This Stack?

1. Hugo: Speed & Simplicity

Hugo is a static site generator (SSG) written in Go. It compiles your content (Markdown) into pure HTML/CSS/JS in milliseconds.

  • No Database: No SQL injections, no connection pools.
  • Portability: The output is just files; host them anywhere.

2. Cloud Run: Scale to Zero

Google Cloud Run is a managed compute platform that runs containers.

  • Free Tier: You get 2 million requests per month for free.
  • Scale to Zero: If no one visits your site, you pay exactly $0.
  • HTTPS Included: Automatic SSL certificates.

Step 1: Initialize Your Hugo Site

First, install Hugo on your machine (Mac example):

brew install hugo

Create a new site:

hugo new site my-blog
cd my-blog
git init

For this blog, I decided to build a custom minimal theme from scratch rather than using a bloated template. This keeps the CSS payload tiny (~4KB) and ensures I have full control over the design.

Step 2: Containerize with Docker

To run on Cloud Run, we need to package our static files into a container. We can use Nginx to serve the content.

Create a Dockerfile in your root directory:

# Stage 1: Build the static site
FROM hugomods/hugo:exts as builder
WORKDIR /src
COPY . .
RUN hugo --minify

# Stage 2: Serve with Nginx
FROM nginx:alpine
COPY --from=builder /src/public /usr/share/nginx/html
WORKDIR /usr/share/nginx/html
EXPOSE 8080

This multi-stage build enables us to have a lightweight final image (just Nginx + HTML) without carrying the Hugo binary or source files.

Step 3: Deployment

You don’t need complex CI/CD pipelines to get started. You can deploy directly from your terminal using the Google Cloud SDK.

Build and deploy in one command:

gcloud run deploy blog-app \
  --source . \
  --region REGION \
  --allow-unauthenticated \
  --project PROJECT-ID

That’s it! Cloud Run will build your container (using Cloud Build behind the scenes), push it to the Container Registry, and deploy it to a URL like https://my-blog-xyz-uc.a.run.app.

Conclusion

By stripping away dynamic rendering and using a “serverless container” approach, you get the best of both worlds: the developer experience of a modern stack and the cost efficiency of static hosting. There is practically no maintenance, and your site can survive a viral hit without breaking the bank.