Workers Static Pages - Dashboard or Wrangler
Hello, I'm attempting to deploy a static site built with zola, and as this is a new project, as per recommendation in Pages docs I'm trying to use Workers instead of Pages.
I already have a repo on GitHub with the site, and I added a
wrangler.toml
with some basic configuration as per migration docs, so name
, compatibility_date
, routes
(a single pattern with custom_domain = true
), assets.directory = "./public/"
, and build.command
set to install and run zola build
(as per this issue).
I went to Cloudflare Dashboard > Compute > Workers & Pages > Create > Workers > Import a repository > Get started, connected to GitHub (org), and after I selected the repo the next step asked me for details of the project, but it said it will create a new Git repo for it. That was a bit confusing, but I went ahead to see what it would do, and it turned out it didn't actually create a new git repo, but used the one I had. However it also didn't seem to pick up any of the settings in my wrangler.toml
as the domains and routes use the default workers.dev domain, etc.
So my question is, could you clarify what is the interaction between Cloudflare Dashboard and Wrangler? Is wrangler only used for integration with external CI/CD? Or can I use wrangler to create a project that uses Cloudflare CI/CD and git integration to automatically build the site on push?
I was looking for a way to configure this through code as much as possible. Would something like Pulumi or Terraform be better for this? (Although from brief look at them it doesn't seem like they can handle Cloudflare CI/CD configuration, nor static pages projects, and look to be more geared toward external CI/CD as well).Cloudflare Docs
Cloudflare Pages
Deploy your Pages project by connecting to your Git provider, uploading prebuilt assets directly to Pages with Direct Upload or using C3 from the command line.
Cloudflare Docs
Migrate from Pages to Workers
A guide for migrating from Cloudflare Pages to Cloudflare Workers. Includes a compatibility matrix for comparing the features of Cloudflare Workers and Pages.
GitHub
v2 build system breaking Zola sites · Issue #3 · cloudflare/pages...
Zola is no longer offered by default by the new build system and it is causing new user's sites to break. Would it be possible to make zola one of the preinstalled tools? I didn't see a pub...
8 Replies
@kahs33_15370 Hey! Just a normal user who is kinda doing the same thing you are.
Only I use Hugo
I think for our use-case, it makes sense to build the worker in the dashboard ui, and set our github repo and things there. Wrangler is great if you're gonna run test servers locally and do more javascript based applications
as for support for Zola, and the formal deployment method. I'd have to do some homework.
for hugo, we tell the build to point to a build script in the wrangler config, but cloudflare is a few releases behind so far.
https://github.com/willduncanphoto/hugo-worker/blob/main/wrangler.toml
https://github.com/willduncanphoto/hugo-worker/blob/main/build.sh
I wouldn't have ever figured that out from the worker documentation
Maybe set up a public repo to attempt the deployment with so we can see your config and build scripts?
With that said, for the time being Cloudflare seems to be saying it's fine to use pages, just dont expect anything to be added or fixed down the road.
Thanks @LordNikon, all good, my zola build looks very similar to your
build.sh
and that part is working OK. So you also have a wrangler.toml
, do any of the settings get picked up in the dashboard, or did you have to set all of them in there manually as well?
If it's the latter, that's good to know I'm not the only one who noticed that. In that case I'll go ahead and set things up manually in the dashboard for now. Thanks!I'm not sending it much, but if I add stuf flike subdomain, it should work fine. Let me see.
it picks up additional info i add to wrangler.toml on the next deploy
https://hugo-sandbox.willduncan.com

passed that through with the wrangler.toml file
GitHub
hugo-sandbox/wrangler.toml at main · willduncanphoto/hugo-sandbox
Contribute to willduncanphoto/hugo-sandbox development by creating an account on GitHub.
name, compat data, route, build command, asset dir and 404 route are all coming from the wrangler file
only thing i did in the dashboard was build the worker, set the git repo, and set an environment variable for a specific hugo build version
after that its all triggered from git push now
I did get an error the first attempt and have to chmod my build.sh file too
chmod +x build.sh
Cool, you're right, after fixing the deployment and one successful build the dashboard picked up the config in my
wrangler.toml
. Splendid, thank you for your help 🫡