Can Pages and Workers be combined?

Hello everyone,

I am using Pages for my Hugo blog. I’m currently testing a small Worker to include comments in my blogposts.
But I am quite confused on how to include and deploy the Worker within my Hugo repository. Can I simply push to github and my Hugo site and Worker gets deployed from there or is that not possibly? Or does the Hugo site also need to be deployed through Workers? So Pages and Workers can’t be used together?

Would be really nice if someone cloud help me clear things up.

Thanks in advance! :slight_smile:

You might be interested in the new announcements from Full Stack Week.

A couple beta notes:

  1. Functions are free, for now (they expect billing similar to Workers, but nothing is finalised) up to 100k reqs/day, you can ask them to increase the limit (read the blog post and docs above).
  2. Deploying APIs to specific paths will cause all requests hitting functions, even if outside the scoped path. They might remove this behaviour and scope correctly.
    If you want to scope correctly deploy Workers separately via GitHub actions, but it requires more work.

@matteo Thanks, that was exactly what I was looking for.

However if I try to deploy a pages functions the route does not seem to work
My file structure looks like this:


So the functions should be available at:*
However this does not work and the build output shows the following under functions → configuration:


  "routes": {},

  "baseURL": "/"


I’m trying for days but can’t get it to work. Is there anything else that I’m missing here?

Thanks in advance :blush:

Is the functions dir in the root set in your Pages configuration?

My root dir is set to “/”, like in your screenshot.

My build log also shows the following:

Compiling worker to “/opt/pages/functions/user-worker.js”