From Obsidian to the site: Cloudflare
- 4 min read
On this page
The site the template builds is just a set of files: HTML, images and styles, in the .site/dist/ folder. Cloudflare stores those files and serves them to your visitors. It does this through a Worker, its service that runs close to the visitor; here, the Worker has no code at all and only serves the files. Requests for static files are neither billed nor limited, so the free plan is enough.
On this page you publish the site once, by hand, from your computer. After that, the automation repeats the same command on every push of the vault.
1. Create the account
Create a free account at dash.cloudflare.com/sign-up. You don’t need a domain.
2. Publish for the first time
Wrangler is Cloudflare’s command-line tool. It does not come with the template, and npx downloads it when you run it. In the .site folder, connect Wrangler to your account:
npx wrangler@4 login
The command opens your browser so you can authorize access. Then build the site and publish it:
npm run build
npx wrangler@4 deploy --assets ./dist --name my-blog --compatibility-date 2026-10-15
What each option does:
| Option | What it is |
|---|---|
--assets ./dist |
The folder with the site’s files, built by npm run build |
--name my-blog |
The Worker’s name. It becomes part of the site’s address |
--compatibility-date 2026-10-15 |
The reference date for the Worker’s behavior. Use the date you first publish and keep it the same afterward |
With these options on the command line, the template needs no Cloudflare configuration file.
When it finishes, Wrangler shows the site’s address, in the form https://my-blog.<your-subdomain>.workers.dev. <your-subdomain> is your account’s workers.dev subdomain, which you can see and change under Workers & Pages in the Cloudflare dashboard.
Go back to .site/astro.config.mjs and put that address in site, as described on the Astro template page. Then run npm run build and wrangler deploy again, and push the vault: until you do, the RSS feed and the sitemap still carry the sample address.
3. Connect your own domain (optional)
The workers.dev address works and is free. Cloudflare itself recommends your own domain for sites that are not personal projects. To use a domain of your own:
- The domain has to be on Cloudflare, either bought there or transferred to it.
- In the dashboard, go to Workers & Pages and pick the
my-blogWorker. - Under Settings → Domains & Routes → Add → Custom Domain, type the domain (for example,
blog.yourdomain.com) and confirm with Add Custom Domain.
Cloudflare creates the DNS record and the certificate by itself. Then change site in astro.config.mjs to the new domain, build, publish and push the vault again.
4. Prepare the automation’s keys
On your computer, wrangler login used your browser session. The automation has no browser: it identifies itself with two pieces of information, which you save now for the next page.
The API token. In the Cloudflare dashboard:
- Open Account API tokens and click Create Token.
- Under Permission policies, choose the Edit Cloudflare Workers template.
- Limit the token to the site’s account and create it.
- Copy the token. It is shown only once.
The account ID. On any dashboard page, open search (Cmd+K on macOS, Ctrl+K on Windows and Linux), type Copy account ID and pick the result. The ID goes to your clipboard.
Keep both in a password manager. In the automation, they are named CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID.
What stays the same from here on
Every publish is the same pair of commands: npm run build and npx wrangler@4 deploy with the same options. On the next pages, the automation runs them for you on every push of the vault: with GitHub Actions or with Azure Pipelines.