Infrastructure|August 21, 20221 min read

Deploy Static HTML Using Cloudflare

Deploy Static HTML Using Cloudflare

You might want to show your portfolio in order to reach a wider audience. One in a million ways to do this is using a web-based portfolio. However, in the beginning, you will struggle with finding a host, domains, and the technical stuff required to launch a website. It can be overwhelming to know everything needed to make a site live.

There is another solution from Cloudflare that can make your life much easier: Cloudflare Workers. It gives us faster performance by using a cutting-edge content delivery network (CDN).

Prerequisites

In order to initiate the setup, we need to install:

  • Node JS
  • NPM

After installing these prerequisites, make sure you have the site files that you want to upload ready on your machine. Then, you can run this command from your terminal or shell:

bash
wrangler generate my-app https://github.com/cloudflare/worker-sites-template

Running this will prompt you to log in using your Cloudflare account and authenticate the session. You can rename "my-app" to anything you want. It will create a folder named "public"; in this folder, put all of your files and assets, including index.html, CSS, JS, and any images.

Change the API settings under the toml configuration file. Once configured, use the command below to publish and push all of your asset files:

bash
wrangler publish

This will publish your assets, creating a workers.dev subdomain containing your project title. Finally, your web application has been successfully deployed!

warning

Issue: If you are using Windows and run scripts through PowerShell, you may need to align your Execution Policy to execute Wrangler scripts. Detailed solutions can be found in the official Microsoft documentation.

CLOUDFLAREWORKERSSTATIC
UA

ulil albab

Technical M&A Lead & Infrastructure Architect

💬 Ask me about How to increase productivity, dealing with repetitive jobs and project management.

Precision in your inbox.

Quarterly briefings on M&A technical strategy, automation frameworks, and infrastructure excellence. No noise, just engineering depth.