Publishing a website on the internet

Lesson 17 of 17 · HTML, CSS and JavaScript

Nobody else sees a site that works only on your computer. A static site – HTML, CSS, JavaScript and images, like the Logo creator – can be published for free in a few minutes. This lesson covers the check before publishing, three ways of publishing and connecting your own domain.

Before you start: required prior knowledge – the logo generator, how the internet works (DNS).
How to learn: do the tasks at the end on your own in your editor first; open the hint and the solution only after that. Every example has the code and a live result below it; type the code into your own file and change it.

Before publishing: a checklist

CheckHow
the home page is called index.htmlthe server shows index.html when only the site's address is opened – rename home.html and change the links to it
all paths are relative and have the correct upper/lower caseimages/logo1.png, not C:\... and not Images/Logo1.PNG
every page has a title and a meta descriptionlook at the head of every page
all images have alt and are not too largephotos up to ~300 KB; shrink them, e.g. with the Squoosh tool
the HTML has no errorsW3C validator – upload the file and fix the reported errors
it works on a phoneF12 → device mode; check the menu and the forms
the site icon (favicon)<link rel="icon" href="images/favicon.png"> – e.g. your logo at 64×64
no personal datado not publish an address, a phone number or photos of others without permission

Way 1: GitHub Pages

GitHub Pages publishes a site directly from a GitHub repository. Along with it you also get the history of all changes (Git).

  1. Create an account on github.com (if you are younger than 13, a parent or teacher creates the account).
  2. New repository → a name, e.g. logo-creator → Public → Create.
  3. Add file → Upload files → drag all the site's files and folders → Commit changes.
  4. Settings → Pages → Source: Deploy from a branch, branch main, folder / (root) → Save.
  5. After a minute or two the site is at the address https://username.github.io/logo-creator/.

Later changes: Upload files again (files with the same name are replaced), or work with Git from VS Code (Source Control).

Way 2: Netlify Drop and Render

ServiceHowNote
Netlify Dropdrag the whole site folder onto the page → you get an address right awaythe fastest; for a permanent site create a free account
RenderNew → Static Site → connect a GitHub repositoryevery change on GitHub is published by itself; this site also runs on Render
a school server / hostingthe files are transferred with an FTP program (e.g. FileZilla)an older way, still common

All these services for static sites are free and automatically include HTTPS (the lesson Security).

Your own domain

An address like name.github.io or name.netlify.app is free. For an address like logocreator.com the domain is rented from a registry (about 10–20 € a year), and then a record that points to the service is added to the domain's DNS:

RecordExampleFor
CNAMEwww → username.github.iothe www subdomain
A@ → the IP addresses the service givesthe main domain without www

How DNS works is explained in the lesson How the internet works. Every service states exactly in its settings (Custom domain) which records need to be added.

Practice tasks

Each task has an example, a hint and a solution. The solutions have been checked in the browser.

TASK 01Difficulty: medium

Publish your project

Go through the checklist for the Logo creator (or your own site), publish it on GitHub Pages or Netlify and send the address to a teacher or a friend. Ask them to open the site on a phone and tell you what is not clear.

Common mistakes and tips
  • On a server upper and lower case in file names are different – on Windows they are not, so the error goes unnoticed until the site is published.
  • If the site is not in the root of the domain (e.g. .../logo-creator/), paths that start with / do not work – use relative paths.
  • Do not publish passwords, API keys or personal data – the whole world sees everything in a public repository.
  • After a change wait a minute and reload the page with Ctrl+F5 (it bypasses the cache).

Check your knowledge

Open the quiz

Publishing a site

1. What should the home page of a site be called?




2. Why does an image work on Windows, but not after publishing?



3. Which DNS record connects the www subdomain with a github.io address?