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
- Step 1: Create the blog in Rankwise
- Step 2: Create the Worker
- Step 3: Add the route
- Step 4: Check the blog
- Troubleshooting
The setup takes about ten minutes.
What you need
- A Rankwise account. The 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 or Nginx setup instead, if your site runs on one of them.
Step 1: Create the blog in Rankwise
- Sign up for Rankwise. On the free blog page, choose Put it on my own domain at /blog instead.
- Open the setup for the blog. Choose On my own site.
- Choose A path, like /blog.
- Enter the blog name, one line about the blog, your website (for example https://yourdomain.com) and the path, for example /blog.
- Click Create my blog.
- 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
- In the Cloudflare dashboard, go to Workers & Pages and create a new Worker.
- Replace the Worker's code with the snippet you copied.
- 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.
// 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.
- Open the Worker and go to Settings, then Domains & Routes.
- Click Add, then Route.
- Select your zone and enter the pattern
yourdomain.com/blog*. - 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
- Open yourdomain.com/blog in a browser. You see your blog's index page.
- 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.
- 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:
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 or 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.