# How to Add a Blog at /blog With a Cloudflare Worker

> Serve your free Rankwise blog at yourdomain.com/blog with one Cloudflare Worker. It works in front of any host, as long as your domain's DNS is proxied by Cloudflare.

Canonical page: [https://tryrankwise.com/resources/guides/add-blog-cloudflare-worker](https://tryrankwise.com/resources/guides/add-blog-cloudflare-worker). Updated 2026-10-30. Published by Rankwise (tryrankwise.com).

A **Cloudflare Worker** can put a blog at yourdomain.com/blog without any change to your website. The Worker sits in front of your site. It sends every /blog request to your Rankwise blog and lets every other request pass to your site as before.

This works with any host behind Cloudflare, because the Worker never touches your site's code. Readers and search engines only see your address.

**In this guide:**

- [What you need](#what-you-need)
- [Step 1: Create the blog in Rankwise](#step-1-create-the-blog-in-rankwise)
- [Step 2: Create the Worker](#step-2-create-the-worker)
- [Step 3: Add the route](#step-3-add-the-route)
- [Step 4: Check the blog](#step-4-check-the-blog)
- [Troubleshooting](#troubleshooting)

The setup takes about ten minutes.

## What you need

- **A Rankwise account.** The [free blog](/free-blog) is enough. It covers 10,000 visits a month.
- **Your domain on Cloudflare.** Cloudflare's docs say a Worker route needs an active Cloudflare zone.
- **A proxied DNS record.** The record for yourdomain.com (or www) must be proxied by Cloudflare, shown as an orange cloud. A record set to "DNS only" never reaches the Worker.
- **A free path.** Pick a path your site does not use yet. This guide uses /blog.

Some hosts ask you to turn the Cloudflare proxy off for their custom domains. Check your host's docs first. If your host does not allow the proxy, use the [Next.js](/resources/guides/add-blog-nextjs-vercel) or [Nginx](/resources/guides/add-blog-nginx) setup instead, if your site runs on one of them.

## Step 1: Create the blog in Rankwise

1. Sign up for Rankwise. On the free blog page, choose **Put it on my own domain at /blog instead**.
2. Open the setup for the blog. Choose **On my own site**.
3. Choose **A path, like /blog**.
4. Enter the blog name, one line about the blog, your website (for example https://yourdomain.com) and the path, for example /blog.
5. Click **Create my blog**.
6. Rankwise shows three snippets. Pick **Cloudflare Worker** and copy it.

The snippet holds your blog's token. Rankwise shows the token only once, so copy the whole snippet before you leave the page.

This guide covers a blog at a path. To put the blog on a subdomain like blog.yourdomain.com, choose **A subdomain, like blog.yourdomain.com** instead. The snippet then forwards every path on that host, so copy it from the app rather than from this page.

## Step 2: Create the Worker

1. In the Cloudflare dashboard, go to **Workers & Pages** and create a new Worker.
2. Replace the Worker's code with the snippet you copied.
3. Deploy the Worker.

The snippet looks like this. Rankwise fills in your own blog id and token, so always paste the copy from the app.

```js
// Cloudflare Worker. Add a route for yourdomain.com/blog* to this Worker.
const PREFIX = "/blog"
const UPSTREAM = "https://rankwiseblog.com/hosted/YOUR-BLOG-ID"
const TOKEN = "YOUR-TOKEN"

export default {
  async fetch(request) {
    const url = new URL(request.url)
    if (url.pathname !== PREFIX && !url.pathname.startsWith(PREFIX + "/")) {
      return fetch(request)
    }
    const rest = url.pathname.slice(PREFIX.length)
    const headers = {
      accept: request.headers.get("accept") || "text/html",
      "x-rankwise-blog-token": TOKEN,
      "x-rankwise-forwarded-host": url.host,
      "x-rankwise-visitor-ip": request.headers.get("cf-connecting-ip") || ""
    }
    for (const name of ["referer", "content-type", "user-agent"]) {
      const value = request.headers.get(name)
      if (value) headers[name] = value
    }
    const post = request.method === "POST"
    return fetch(UPSTREAM + rest + url.search, {
      method: post ? "POST" : "GET",
      body: post ? request.body : undefined,
      headers,
      redirect: "manual"
    })
  }
}
```

Here is what each part does:

- **PREFIX** is the path of your blog on your site.
- **The first check** sends every request outside /blog straight to your site with `fetch(request)`. Your site sees those requests exactly as before.
- **The headers** carry the token, so Rankwise knows the request comes from your Worker, and your hostname, so Rankwise knows the page is served on your domain. The visitor's IP address lets Rankwise limit spam sign-ups to your newsletter form. The referrer lets the blog's visit stats show where readers come from.
- **The second fetch** asks Rankwise for the blog page. It passes a POST and its body through, so the newsletter form at the end of each post works. `redirect: "manual"` sends the form's "check your inbox" redirect back to the reader.

## Step 3: Add the route

A route tells Cloudflare which requests run the Worker.

1. Open the Worker and go to **Settings**, then **Domains & Routes**.
2. Click **Add**, then **Route**.
3. Select your zone and enter the pattern `yourdomain.com/blog*`.
4. Click **Add route**.

If your site runs on www, use `www.yourdomain.com/blog*` instead. If both hostnames serve your site, add a route for each.

A pattern that ends in `*` matches every path that starts with /blog. That includes paths like /blogroll. The Worker checks the path again and sends those requests straight to your site, so nothing else changes.

## Step 4: Check the blog

1. Open yourdomain.com/blog in a browser. You see your blog's index page.
2. Back in Rankwise, click **Check my blog**. Rankwise opens your /blog page and looks for your blog's tag. When it finds it, the blog shows as connected.
3. Open yourdomain.com/blog/llms.txt and yourdomain.com/blog/sitemap.xml. Both list your posts once you publish one.

To check that search engines may index the blog, run this in a terminal:

```bash
curl -sI https://yourdomain.com/blog/
```

The answer must not contain `x-robots-tag: noindex`. Rankwise sends that header when a request does not carry the right token and hostname, so the copy on our server never competes with yours.

## Troubleshooting

**The blog page shows my own site's 404 page.** The route does not match. Check the hostname in the route (with or without www) and that the DNS record is proxied.

**The page loads, but the header says noindex.** The token or hostname does not match. Copy the snippet again from Rankwise, so the token is current, and redeploy the Worker. Check that **Your website** in the Rankwise setup is the domain in the address bar.

**Check my blog fails.** Rankwise could not find the blog on your page. Confirm that yourdomain.com/blog shows the blog, wait a minute, and try again.

**My host tells me to turn the Cloudflare proxy off.** A Worker route only runs on proxied records. Use a different setup, such as [Next.js middleware](/resources/guides/add-blog-nextjs-vercel) or [Nginx](/resources/guides/add-blog-nginx).

Once the blog is live, every post you publish appears at yourdomain.com/blog with its sitemap entry, RSS item, llms.txt line and Markdown copy.
