---
title: "Cloudflare Static Website"
description: "Deploy a static website on Cloudflare with Pulumi and Cloudflare Workers in TypeScript, Python, Go, C#, YAML, or HCL."
url: "https://www.pulumi.com/dev/templates/static-website/cloudflare/"
image: "https://www.pulumi.com/assets/og/dev/templates/static-website/cloudflare.png"
---

# Cloudflare Static Website

Deploy a static website on Cloudflare with Pulumi and Cloudflare Workers in TypeScript, Python, Go, C#, YAML, or HCL.

The Cloudflare Static Website template scaffolds a Pulumi project that serves your site's files as static assets from a [Cloudflare Worker](https://www.pulumi.com/registry/packages/cloudflare/api-docs/worker/), exposed on its own `workers.dev` subdomain. Pulumi uploads the contents of the site folder as a versioned set of [Worker assets](https://www.pulumi.com/registry/packages/cloudflare/api-docs/workerversion/) and rolls that version out to all of the Worker's traffic with a [Workers deployment](https://www.pulumi.com/registry/packages/cloudflare/api-docs/workersdeployment/). The template ships with placeholder web content so the project deploys end to end out of the box.

![An architecture diagram of the Cloudflare Static Website template](./architecture.svg)

## Using this template

To use this template to deploy a website of your own, make sure you've [installed Pulumi](https://www.pulumi.com/docs/install/) and [configured your Cloudflare credentials](https://www.pulumi.com/registry/packages/cloudflare/installation-configuration/), then create a new [project](https://www.pulumi.com/docs/iac/concepts/projects/) using the template in the language of your choice:

**TypeScript**

```bash
mkdir my-site && cd my-site
pulumi new static-website-cloudflare-typescript
```

**Python**

```bash
mkdir my-site && cd my-site
pulumi new static-website-cloudflare-python
```

**Go**

```bash
mkdir my-site && cd my-site
pulumi new static-website-cloudflare-go
```

**C#**

```bash
mkdir my-site && cd my-site
pulumi new static-website-cloudflare-csharp
```

**YAML**

```bash
mkdir my-site && cd my-site
pulumi new static-website-cloudflare-yaml
```

**HCL**

```bash
mkdir my-site && cd my-site
pulumi new static-website-cloudflare-hcl
```

Follow the prompts to complete the new-project wizard. When it's done, you'll have a complete Pulumi project that's ready to deploy and configured with the most common settings. Feel free to inspect the code in `index.ts` for a closer look.

## Deploying the project

The template needs one setting to deploy: the [Cloudflare account ID](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/) to deploy into. Set it, then deploy with [`pulumi up`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_up):

**TypeScript / Python / Go / C# / YAML**

```bash
$ pulumi config set accountId <your-account-id>
$ pulumi up
```

**HCL**

```bash
$ pulumi config set account_id <your-account-id>
$ pulumi up
```

When the deployment completes, Pulumi exports the following [stack output](https://www.pulumi.com/docs/iac/concepts/stacks/#outputs) value:

**`url`**

The fully-qualified HTTPS URL of the deployed website on its `workers.dev` subdomain.

Output values like this one are useful in many ways, most commonly as inputs for other stacks or related cloud resources. The computed URL, for example, can be used from the command line to open the newly deployed website in your favorite web browser:

```bash
$ open $(pulumi stack output url)
```

## Customizing the project

Projects created with the Static Website template expose the following [configuration](https://www.pulumi.com/docs/iac/concepts/config/) settings:

**TypeScript / Python / Go / C# / YAML**

**`path`**

The path to the folder containing the files of the website. Defaults to `./www`, which is the relative path of the folder included with the template.

**HCL**

**`path`**

The path to the folder containing the files of the website. Defaults to `./www`, which is the relative path of the folder included with the template.

This setting is optional and may be adjusted either by editing the stack configuration file directly (by default, `Pulumi.dev.yaml`) or by changing its value with [`pulumi config set`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_config_set).

### Using your own web content

If you already have a static website you'd like to deploy on Cloudflare with Pulumi, you can do so either by replacing the placeholder content in the `www` folder or by configuring the stack to point to another folder on your computer with the `path` setting:

```bash
$ pulumi config set path ../my-existing-website/build
$ pulumi up
```

## Cleaning up

You can cleanly destroy the stack and all of its infrastructure with [`pulumi destroy`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_destroy):

```bash
$ pulumi destroy
```

## Learn more

- Browse other architecture templates in the [Templates gallery](https://www.pulumi.com/templates).
- Explore the [Cloudflare provider API docs](https://www.pulumi.com/registry/packages/cloudflare) in the Pulumi Registry.
- Walk through Pulumi from the ground up in [Pulumi Tutorials](https://www.pulumi.com/dev/browse/?type=tutorial).
- Read the latest [Cloudflare posts on the Pulumi blog](https://www.pulumi.com/blog/tag/cloudflare).
