Asif Rahman

Cloudflare pages for static hosting

The asifr.com website has been hosted on a cheap DigitalOcean server for the last 8 years. I hadn’t touched the server for many years and it stagnated running Ubuntu 14 and didn’t have HTTPS. Today, I migrated the static site to Cloudflare Pages for free hosting in two steps:

  1. Create a github repository with the static files. The repo can be public or private.
  2. Connect Cloudflare pages to the github repo and set the path to the static files in your repo (e.g. /public or /dist).

Offline, I use pandoc to compile a folder of Markdown files into static HTML files.

Cloudflare Pages automatically rebuilds the site when I commit the changed files to the github repo. However, since we don’t have a cloud-based build step and are generating the static files offline, Cloudflare Pages simply serves the public static files.

Cloudflare gives a nice domain name: asifr.pages.dev, but also provides custom DNS service so I can point asifr.com to asifr.pages.dev. It takes a few hours for the domain name propagation once the nameservers are transferred and the CNAME is created. Now asifr.com has secure HTTPS connections and is served from Cloudflare’s edge network.

The benefits are: I get a free hosting service since Cloudflare Pages provides unlimited bandwidth, requests, and sites (the limitation of the free-tier is I get 500 builds per month – which is plenty for a simple personal site that is updated infrequently). You also get security, HTTPS, analytics, and users get fast access to the site from anywhere in the world.