Publishing

Subdirectory

Serve your Contito site from a folder of your existing website, like www.example.com/docs, through a Cloudflare Worker.

A subdirectory puts your Contito site inside your main website's address: www.example.com/docs or www.example.com/blog.

Your main site stays where it is. Contito serves only that folder.

Why a subdirectory

Search engines see one website, so every visit and link to your docs or blog builds up your main domain.

A separate address like docs.example.com or example.contito.org counts as a site of its own.

Subdirectories are on Pro and Ultimate. On Starter, the Subdirectory section shows a lock and Upgrade to unlock.

What you need

  • A Cloudflare account. The free plan works.
  • Your domain on Cloudflare, with its DNS record Proxied (the orange cloud in Cloudflare's DNS settings).

Contito connects through a Cloudflare Worker: a small piece of code that runs on Cloudflare and forwards every request for your folder to Contito.

Contito writes the code for you. You paste it.

1. Enter the address

  1. Open your site and click Settings.
  2. Under Hosting, click Subdirectory.
  3. Type your domain with the folder, like www.example.com/docs, and click Save.

The Subdirectory section with www.example.com/docs typed and Save marked

#What it does
1Your domain and folder. Lowercase only, in the form example.com/docs.
2Save: shows the Worker setup.

2. Create the Worker

After saving, Setup Cloudflare Worker lists three values.

Click any box to copy its contents.

The Subdirectory section after saving, with Worker Name, Code, Route and the Waiting for your Worker status marked

#What it isWhere it goes in Cloudflare
1Worker Name, like www-example-com-docs-to-contitoThe name of the new Worker
2CodeReplaces all of the Worker's starter code
3Route, like www.example.com/docs*The Worker's route, in the zone that covers your domain
4Connection statusShows Connected once it works

In the Cloudflare dashboard:

  1. Go to Workers & Pages and select Create application.
  2. Select Start with Hello World!
  3. Give it the Worker Name from Contito and click Deploy.
  4. On the Worker's main page, click Edit code to open the code editor. Delete everything in it, paste the Code from Contito and click Deploy.
  5. Back on the Worker's main page, click Domains, then Add a route under Routes.
  6. On the custom domains and routes page, click Add Route. Pick the zone (your domain) and paste the Route from Contito, including the * at the end.

Cloudflare's Deploy Hello World screen with the Worker name filled in

#What it does
1Worker name: paste the Worker Name from Contito.
2Deploy: creates the Worker.

Cloudflare's code editor with Contito's code pasted in and the Deploy button

#What it does
1The code: replace everything with the Code from Contito. Your copy has your own values on the first two lines.
2Deploy: puts the new code live.

Cloudflare's Add Route dialog with the zone and the route from Contito filled in

#What it does
1Zone: your domain.
2Route: paste the Route from Contito, with the * at the end.
3Add Route: saves it.

The code holds a key that proves requests come from your Worker.

It gives no access to your Contito account or content, but anyone who has it can show your pages on their own domain, so don't share the code.

If it gets out, click Regenerate key and paste the new code into your Worker. The old key stops working.

3. Connect

Open your new address, such as www.example.com/docs, in a browser.

The Visit Website button in Contito does the same.

The first visit through your Worker connects the site.

The status changes from Waiting for your Worker to Connected.

The Subdirectory section showing www.example.com/docs with the Connected badge

Once connected, the setup steps fold away under Show Cloudflare Worker setup.

From then on, search engines index the site at your subdirectory.

Status messages

StatusMeaning
Waiting for your WorkerContito is watching for the first visit through your Worker.
No traffic from your Worker yetNo visit arrived in the first few minutes. Check the Worker, visit the address, then click Check again.
ConnectedVisits are coming through. The subdirectory is live.

Your site stays reachable at its other addresses the whole time.

Change or remove the subdirectory

Click Edit next to the address.

  • To change it, type the new address and click Save. A new address gets a new key, so paste the new Code into your Worker and update its Route.
  • To take it off, click Remove, then delete the Worker in Cloudflare.

Troubleshooting

It says No traffic from your Worker yet

Check three things in Cloudflare: the Worker is deployed with Contito's code, its route matches the Route in Contito exactly (with the *), and your domain's DNS record is Proxied.

Then open your subdirectory address and click Check again.

My main site shows up at /docs instead of Contito

The Worker isn't running on that address. Check the route's zone and pattern in the Worker's settings.

My domain isn't on Cloudflare

The subdirectory setup needs Cloudflare. Use a Custom Domain like docs.example.com instead, which works with any DNS provider.

How do I add the subdirectory to Google Search Console?

The main site's property covers it. One extra step points Google at the blog's sitemap. See Google Search Console .