Get Started

Put your website online free with GitHub Pages and Cloudflare Pages

A website is just a folder of files, and two big companies will host that folder for nothing. Your site is live on GitHub Pages in about 35 minutes, then Cloudflare Pages adds preview addresses and one-click rollbacks.

85 minIntermediateTools: Free (GitHub Free and Cloudflare Free plans)Step 1 free
A ready-made one-page site (HTML and CSS, no build step) with a proper 404 page, in a starter kit
The site live on GitHub Pages at username.github.io/my-first-site, updated with one git push
The same site on Cloudflare Pages, with preview addresses for every branch and one-click rollbacks
  • Uploading straight from your PC with Wrangler, no Git needed
  • A GitHub Actions workflow for sites with a build step (Vite, Astro and similar), and a clear rule for which host to pick
Before you start
01/07Get the starter site and preview it on your PC0 done
STEP 01 of 07~10 min

Get the starter site and preview it on your PC

Always look at a site on your own computer before it goes public. It's faster, and mistakes stay private.

  1. Download the starter kit: my-first-site.zip (7KB). It's a one-page site for a sample bike mechanic, written in plain HTML and CSS so there's nothing to install or build. Swap the words for yours.

    The starter site on a laptop in light mode and on a phone in dark mode: a bike repair page with a big headline, two buttons and price cards
    The starter site. It follows the visitor's light or dark setting and fits a phone screen without any extra work.
  2. Unzip it into a folder called Sites in your home folder:

    Windows
    mkdir $HOME\Sites -Force
    Expand-Archive $HOME\Downloads\my-first-site.zip -DestinationPath $HOME\Sites
    cd $HOME\Sites\my-first-site
    Mac
    mkdir -p ~/Sites && unzip ~/Downloads/my-first-site.zip -d ~/Sites
    cd ~/Sites/my-first-site
  3. Here's what's inside. The website itself is only the docs folder; everything else stays in your repository but never gets published:

    • docs/index.html: the page. All the words are here.
    • docs/styles.css: colours, spacing and layout. The colours are the -- lines at the top.
    • docs/404.html: shown when someone visits an address that doesn't exist.
    • docs/favicon.svg: the icon in the browser tab.
    • docs/.nojekyll: an empty file that tells GitHub Pages to publish the files exactly as they are (step 3 explains).
    • .gitignore: keeps junk files and any .env secrets file out of Git.
    • extras/deploy-vite-to-pages.yml: a workflow for sites with a build step. Ignore it until step 7.
  4. Now serve the folder like a real web server would. --bind 127.0.0.1 keeps it visible only to your own PC, not everyone on your Wi-Fi:

    Windows
    python -m http.server 8000 --bind 127.0.0.1 --directory docs
    Mac
    python3 -m http.server 8000 --bind 127.0.0.1 --directory docs
    Output
    Serving HTTP on 127.0.0.1 port 8000 (http://127.0.0.1:8000/) ...
  5. Open localhost:8000 ↗. Each file the browser asks for shows up in the terminal as a line with 200 (found) in it. Then try localhost:8000/old-page ↗: you get Python's plain error page and a 404 line. That's expected. Python's little server doesn't use custom 404 pages, but both hosts will.

  6. Make it yoursOpen docs/index.html in any text editor (Notepad is fine, VS Code is nicer), change the name, headline, services and email, save, and refresh the browser. Change --accent in styles.css to change the main colour.

  7. Why every link has no slash at the startThe page loads styles.css, not /styles.css. On GitHub Pages your site lives in a sub-folder (username.github.io/my-first-site/), so /styles.css would point at username.github.io/styles.css, which doesn't exist, and the page would load with no styling. Relative links work in both places. The 404 page does the opposite and keeps its styles inside the file, because it's shown at any broken address in any folder.

    CarefulEverything in docs will be public, and on GitHub Free the whole repository is public too. No passwords, API keys, private notes or your home address. An email address on a public page will attract spam, so use one you don't mind giving out.
  8. Press Ctrl + C in the terminal to stop the server when you're done.

✓
Checkpointlocalhost:8000 shows your edited page with its colours and icon, and the terminal shows 200 lines for / and /styles.css.
If it breaks'python' is not recognised, or the Microsoft Store opens + 2 more
'python' is not recognised, or the Microsoft Store opens
Install Python as shown in Install anything from GitHub, safely, and switch off the two Python App execution aliases in Windows Settings. Then open a new terminal.
'Only one usage of each socket address' or 'Address already in use'
Something else is using port 8000. Use another number, like 8001, in the command and the address.
The page loads but looks like a plain 1990s document
The browser can't find styles.css. Check you ran the command from the my-first-site folder with --directory docs, and that the file is still called styles.css in lower case.
Still stuck? Ask the community
Next mission · Build things with codePoint your own domain at your site, with HTTPS
→