You have a finished project. It runs on your computer, it looks good, it works. And still nobody will ever see it, because the last step, getting it onto the internet, looks like a completely different discipline.
It isn't. In twenty minutes you can have a live address and you won't pay anything for it. We'll go through it from the start, and I won't hide the places where it usually gets stuck.
What you need to have ready
Before you start, three things:
- A project that can be run from a clean folder. That means: you clone it somewhere else, install the dependencies, run the build and it passes.
- A GitHub account. Free. Deployment starts from the repository, not from your disk.
- A hosting account. For static sites and Next.js projects the easiest options are Vercel or Netlify, both have a free tier for personal projects. For a purely static output, GitHub Pages or Cloudflare Pages work too.
tip
Free here means "no credit card for a personal project". Free tiers have limits on traffic and build time. For a portfolio, a blog or a project showcase, those are limits you won't hit. Once you have real traffic, you'll deal with it, but that's a nice problem to have.
Step 1: check the build on your computer
This is the step ninety percent of people skip, and then they stare at a red log for ten minutes. Development mode and a production build are not the same thing. Development forgives errors that the build won't let through.
npm install
npm run buildIf the build passes, move on. If it doesn't, fix it now. The error you see here is the same error you'll see on the server, you just solve it faster here.
The most common snags in this step:
- An unused variable or import that development mode tolerates and the build doesn't.
- A missing type in TypeScript that you "solved" by ignoring the warning.
- A file you have on your disk but that isn't in git. The whole next step is about that.
Step 2: get it onto GitHub
git init
git add .
git commit -m "prvni verze"Now an important pause. Before you send anything, check what you're sending:
git statusThe list must not include .env, .env.local, the node_modules folder or
anything that contains keys, passwords or tokens. If a file like that is there,
add it to .gitignore and remove it from the index:
echo ".env.local" >> .gitignore
git rm --cached .env.local
git commit -m "vyradit lokalni promenne z gitu"A key you push to a public repository even once is exposed forever, even if you delete it right away. The history stays. The only right response is to generate a new one and revoke the old one.
Then create an empty repository on GitHub and connect it:
git remote add origin https://github.com/tvoje-jmeno/tvuj-projekt.git
git branch -M main
git push -u origin mainStep 3: connect the repository to your hosting
On Vercel and Netlify it's the same process: you sign in with your GitHub account, choose to import a project and pick the repository. It usually recognizes the framework on its own and pre-fills the build command and the output folder.
Check two fields:
- Build command. Usually
npm run build. - Output directory. For Next.js the hosting handles it on its own, for static
generators it's usually
distorout.
You confirm and wait. The first build takes longer than the ones after it, because all the dependencies get downloaded. When it finishes, you get an address. Click it.
Step 4: environment variables
This is where it breaks most often. Locally you have .env.local with your API
keys. You correctly didn't put it in git. And that's why the server doesn't know
about it.
In your project settings on the hosting, find the Environment Variables section and enter the same values you have locally. Then run the build again, because the variables are loaded at build time, not at runtime.
Watch out for one thing: a variable with the NEXT_PUBLIC_ prefix ends up in the
code that runs in the browser. That means every visitor can see it. Never put
anything secret there.
What goes wrong and how to tell
The build passes locally but not on the server
It's almost always a difference in letter case in file names. Windows and macOS
treat Header.tsx and header.tsx as the same file, Linux on the server doesn't.
Check that your imports match the file name exactly.
The second possibility is a different version of Node.js. You can lock the version in the project settings, so set it to the one you have locally.
The page loads but the images are missing
Paths. Locally ./obrazky/foto.jpg works, on the server it doesn't, because the
page runs at a different level of the address. Use paths from the root, so
/obrazky/foto.jpg, and keep the files in the public folder.
Changes don't show up
You deployed, but you see the old version. Before you start hunting for a bug, open the page in a private window. Nine times out of ten it's the browser cache, not a bad deployment.
Your own domain doesn't work right away
When you connect your own domain, you set the DNS records the hosting shows you at your registrar. The change doesn't spread instantly. It can take a while before it shows up everywhere, and it's normal for the site to load on mobile data but not yet on your home network. Don't reconfigure it every half hour, that only drags it out.
What to do right after
Deploying isn't the end, it's the start of a loop. From now on a simple rule applies: every push to the main branch means a new deployment. So:
- Don't work directly in the main branch. Create a branch, experiment there, then merge.
- Run the build locally before every push. It takes a moment and saves you some embarrassment.
- Look at the finished page on a phone. Not in a shrunken browser window, on a real phone.
And then send it to someone. That's the whole point of it being on the internet. A project nobody has seen is still just a folder on your disk.
I show the process on a live project in the videos (the videos are in Czech), and you'll find the ready-made prompts and skills I use for it in the tools.
Kafe a cígo, fajně si sednout a jdeme na to.
Coffee and a smoke, get comfy and let's go.
Vojta Horava
Want to know when the next one is out?
Now and then I write about what's new: a video, a tool, an article. Unsubscribe with one click.
