logo
How To Create a Website on Cloudflare
25 March 2026
Note: this was written on 25 March 2026. Cloudflare's site changes quickly, but the gist of the steps should be the same.

You can set up a website and have Cloudflare serve it for free. You get your content distributed to edge machines globally, lots of security and protection, compression, encryption, SSL tokens, etc. Cloudflare is a lot easier to set up and maintain than using AWS.

  1. create a domain name  (or use one you already have)
  2. upload content using one of several methods:
  3. set up additional configuration information

    Other Things To Do

    Now that you have connected your custom domain to cloudflare's pages mechanism, there are several things to do to finish up (such as setting up error pages, redirecting apex to www, toggling builds, etc).

    How to redirect http to https

    always use https  
    go to SSL/TLS
    turn off encryption
    go to edge certificates
    turn on Always Use HTTPS

    How to redirect apex/root to www

    for example: https://yoursite.com to https://www.yoursite.com
    cloudflare go to yoursite.com
    pick DNS records on left and add DNS record:
    A @ 192.0.2.1 proxied
    pick rules on left side
    pick template button over on the right by add (picture):
    add template rule to redirect root to www
    if the button is not there, then pick the template box on the page
    labeled:
    Redirect from root to www
    use the defaults:
    incoming match: wildcard pattern
    request URL https://yoursite.com/*
    Then redirect to target URL: https://www.yoursite.com/${1}
    check the preserve query string

    How To redirect a url to another one cloudflare website

    redirecting a domain  
    create two records on the from url:
    A @ 192.0.2.1 Proxied
    A www 192.0.2.1 Proxied
    create rule
    go to rules → overview in the left column
    use template for redirect to a different domain
    all incoming requests
    change to static, leave the code 301
    put in https://www.richgossweiler.place

    Setting Up Error Redirection

    When an error occurs on your site, a generic 404 page will appear. If you create an error.html page in the root (public/error.html) you can customize the page (just remember to use absolute references since who knows where you are on the site the person is when they 404).

    Since github also has a Pages system, but uses a 404.html page in the repo's root (not public/error.html), I do the following:
    1. on github I create a 404.html page that redirects to public/error.html
    2. I create a public/error.html page that has full paths (no relative links)

    www.yoursite.com/404.html:
    <meta http-equiv="refresh" content="0; url=https://<userid>.github.io/www.yoursite.com/public/error.html"/> 


        github www.yoursite.com repo directory structure:
          README.md
          404.html
          public/
            error.html
            error.css
            index.html
            index.css


    If I don't want a custom error page for every repo, I point it to an error page for my general github:
    www.yoursite.com/404.html:
    <meta http-equiv="refresh" content="0; url=https://<userid>.github.io/404.html" />


    You can snag a template for this on github at templateWebApp  

    Disable Automatic Builds on Branches

    Sometimes you don't want every push to the remote github repo to generate a build for the production deployment.

    You can skip a cloudflare build by adding a prefix to the commit message: commit -m [CI skip] ...

    You can also turn off automatic builds:
    1. Compute&AI → workers & pages → go to your pages project
    2. go to Build → edit branch control → turn off automatic branch deployments
    3. or change Preview Branch ot None (Disable automatic branch deployments)

    Remove Cloudflare access to the Github Repo

    To Remove cloudflare access to github repo go to the applications page on github https://developers.cloudflare.com/pages/configuration/git-integration/github-integration/ To Remove cloudflare access to github repo go to the applications page on github (see this   for more information).

References

cloudflare documentation   getting started: direct upload   getting started: direct upload with wrangler   getting started: git integration   learn more in workers builds   cloudflare workers   hosting a static website   always use https   redirecting a domain   templateWebApp   gt: a tool to simplify your git and github repos