Domain Setup

Serving your blog in the /subfolder of your main domain

Serving your blog via a /subfolder on your main domain is accomplished via Cloudflare Workers.

For this setup to work properly, your domain must run via Cloudflare.

Please follow our guide on Setting up your domain in Cloudflare.

After you set up your domain in Cloudflare, follow the instructions below and implement the required scripts for your blogstatic blog to run from your domain's /subfolder.

Important note: Cloudflare, from time to time, changes their flow. If the steps below do not match what you're seeing in Cloudflare, contact us and we'll help you out.

After setting up the /subfolder as described below, do not forget to check on "TLS/SSL" settings under your domain in Cloudflare. They need to be set in "Full" and Cloudflare tends to put them back to "Flexible" when nameservers resolve for the first time.

Setting up your /subfolder

  • Click on "Workers & Pages" > "Overview
  • From there, click the blue button "Create Worker"
    • On the next screen, give it a name
    • Paste the following code into the editor
    • Click "Deploy"
  • On your newly created Worker, click "Configure Worker"
  • On the next page, click on the "Triggers" tab
    • Click "Add Route"
    • Insert yourdomain.com/blog* for the route — do not forget the *
      • blog must match your /subfolder of choice
      • If you are setting up your /subfolder with "www" — add "www" in front of "yourdomain.com/blog*"
    • Select Zone yourdomain.com
    • Also, click on the "Request limit failure mode" link and select "Fail open (proceed)"
      • This makes the URL /blog resolve to the homepage of yourdomain.com if you exceed the 100K requests per day

Give it a few seconds, and visit yourdomain.com/blog. It should show the content from subdomain.bstatic.io

Setting up other functions

When your blog runs via Cloudflare Workers on your domain's /subfolder, we need to implement another script, so other functions (like newsletter signup, etc.) on your blog work properly.

  • Click on "Workers & Pages" > "Overview
  • From there, click the blue button "Create Worker"
    • On the next screen, give it a name
    • Paste the following code into the editor
    • Click "Deploy"
  • On your newly created Worker, click "Configure Worker"
  • On the next page, click on the "Triggers" tab
    • Click "Add Route"
    • Insert yourdomain.com/blog/internal/function for the route
      • blog must match your /subfolder of choice
      • If you are setting up your /subfolder with "www" — add "www" in front of "yourdomain.com/internal/function"
    • Select Zone yourdomain.com
    • Leave "Request limit failure mode" as is

Troubleshooting

  • If you are just moving your domain to Cloudflare, you must give it up to 48–hours for the new Nameservers to resolve globally. Usually, it takes less than that (2, 3 hours). But, that is the maximum that it can take.
  • Make sure the TLS/SSL on the domain level (in Cloudflare) is set to "Full". When Nameservers are resolving for the first time, Cloudflare tends to set back the TLS/SSL to flexible, which will not work.
  • The main domain needs to be proxied via Cloudflare (orange toggle) on DNS management.