How to edit your own Next.js website without breaking it
Where every word and image on a Next.js site actually lives, how to change it right on GitHub, and how to check it before anyone else sees it.
Londynn Metten
· 7 min read
You’ll end up with
A text, image or page-title change live on your site, checked on a preview first
- Time
- 15 minutes a change
- Cost
- Free
- Level
- Beginner
The short answer
To edit a Next.js site, find the file that holds the words or image you want to change (pages live in the app folder, sections in components, images in public), edit it right on GitHub, and save it to a new branch instead of main. Your host builds a preview link for that branch, so you can check the change on your phone before it goes live. When it looks right, merge it and the live site updates in a minute or two. Change the words between the tags and leave the code around them alone.
Where does everything live in a Next.js site?
A Next.js site looks like a lot of files the first time you open it. You’ll only ever touch a handful. Here’s the map for a typical site, including the ones v0 builds.
| What you want to change | Where it usually lives |
|---|---|
| The home page | app/page.tsx |
| Another page, like /about | app/about/page.tsx (the folder name is the web address) |
| A section used on several pages | components/, for example components/hero.tsx or components/footer.tsx |
| Images, logos, the favicon | public/, for example public/images/team.jpg |
| Site-wide title, fonts, header and footer | app/layout.tsx |
| Colors and spacing | app/globals.css |
| Settings you shouldn’t need to touch | next.config.mjs, package.json |
The one idea to hold onto: in the app folder, folders are web addresses. app/services/page.tsx is the page at yoursite.com/services.
In your repository
On your website
app/page.tsxyoursite.com/app/about/page.tsxyoursite.com/aboutapp/services/page.tsxyoursite.com/servicesapp/services/catering/page.tsxyoursite.com/services/catering
How do you find the exact words you want to change?
Don’t hunt through folders. Search for them. Copy a short, unusual phrase from the live page, something like “Open Tuesday to Saturday”, and paste it into the search box at the top of your repository on GitHub.
GitHub shows every file containing that phrase. Nine times out of ten there’s one result, and that’s your file. If a phrase isn’t found, try a shorter piece of it. Long sentences are sometimes split across lines in the code.
What is safe to change, and what should you leave alone?
Open the file and you’ll see your words wrapped in code. Here’s what a typical section looks like.
<section className="py-24"> <h2 className="text-4xl"> Open Tuesday to Saturday </h2> <p className="text-lg"> Walk-ins welcome. Call ahead for groups of six or more. </p> <a href="/contact"> Book a table </a></section>- Safe: the words between tags, like “Open Tuesday to Saturday” or “Book a table”.
- Safe, carefully: what’s inside quotes after href= (where a button goes) or alt= (an image description). Keep both quote marks.
- Leave alone: className=, curly braces { }, and anything that looks like a word joined to another word with a dot.
- If your sentence has an apostrophe and the build complains, use the curly one (’) instead of the straight one.
How do you edit a file right on GitHub?
- 01Open the file on GitHub and click the pencil icon at the top right of the file.
- 02Make your change. Only the words.
- 03Click Commit changes. In the box that opens, write a short note like “Update opening hours”.
- 04Choose “Create a new branch for this commit and start a pull request”, then click Propose changes, then Create pull request.
- 05Wait a minute or two. Your host posts a preview link on the pull request. Open it on your phone and on your computer.
- 06If it looks right, click Merge pull request. The live site updates on its own a minute or two later.
Commit message1
Simplified drawing · real wording may differ slightly
- 1Say what you changed, in plain words. Future you reads this.
- 2Pick the branch option. Main is the live site; a branch is a draft.
- 3Propose, then Create pull request. Your host posts a preview link on it.
Committing straight to main skips the preview and goes live immediately. It’s fine for fixing a typo. For anything else, use a branch.
If you merge something and then spot a mistake, it’s two clicks to reverse. That’s covered in how to undo a bad change.
How do you swap an image?
- 01Make the new image a sensible size first. A photo for a web page should be about 2000 pixels wide at most, and ideally under 500 KB. WebP or JPG both work.
- 02The easy way: give the new file exactly the same name as the old one. In the public folder on GitHub, click Add file, then Upload files, and drop it in. Same name means the code doesn’t change at all.
- 03The other way: upload it with a new name, then search the code for the old file name and change it to the new one.
- 04Update the alt text next to it so it describes the new picture. That’s what screen readers and search engines read.
How do you change the title Google shows?
Each page can say what title and description it wants in search results. Look near the top of that page’s page.tsx for a block called metadata. If a page doesn’t have one, it uses the site-wide one in app/layout.tsx.
export const metadata = {
title: "Wood-fired pizza in Mount Shasta",
description: "Open Tuesday to Saturday. Walk-ins welcome, groups call ahead.",
}While you’re in there, check that the site’s main address is your real domain and not your host’s preview address. If it’s wrong, Google indexes the wrong one. Here’s why Google indexes the wrong domain and the five-minute fix.
How do you add a new page?
Copy a page that already looks close to what you want. If you want a /services page that looks like /about, create a new file at app/services/page.tsx, paste in everything from app/about/page.tsx, and change the words.
Then add a link to it wherever your menu lives, usually a header file in components. Search your repository for an existing menu label like “About” to find it.
When should you edit on your own computer instead?
GitHub’s editor is great for one file at a time. When a change touches several files, or you want to see it instantly as you type, run the site on your own computer.
git clone <repo-url>
cd <repo-folder>
npm install
npm run devOr skip the typing altogether and hand bigger edits to an AI assistant that works on the files for you. That’s part five: editing your site with Claude, ChatGPT or Grok.
When an edit is bigger than it looks
Words, images, titles and links are all safe to do yourself. Layout is where it gets harder. Moving a section, changing how something looks on a phone, or adding a form touches the code around the words, and that’s where a small slip breaks the build.
If the preview fails to build, nothing reaches the live site. Read the first error in the build log, undo your last change, and try again, or paste the error into an AI assistant and ask what it means. A failed preview is a warning, not a disaster.
Common questions
- Do I need to install anything to edit my Next.js site?
- No. GitHub’s website lets you edit any file in the browser, and your host builds a preview for every branch. You only need a code editor and Node on your computer if you want to run the site locally.
- What is a .tsx file?
- It’s a page or section of your site written in TypeScript and JSX, which mixes code with something that looks a lot like HTML. You can treat it like HTML: words between tags are content, everything in angle brackets is structure.
- Will editing a file on GitHub change my live site straight away?
- Only if you commit to main. Commit to a new branch instead and open a pull request. Your host builds a preview from that branch, and the live site changes only when you merge.
- How long until my change shows up on the live site?
- Usually one to three minutes after you merge, while the host rebuilds the site. If it still looks old, refresh with a hard reload, since your browser may be showing a cached copy.
- Can I edit a v0 site this way after I stop using v0?
- Yes. That’s the point. Once the code is on GitHub, it’s a normal Next.js site and you edit it like any other. Just don’t go back to the builder afterwards, or you’ll be editing two different versions.
Keep going
More you can build yourself
Your edits need somewhere to go live. Part four: deploying from GitHub to Cloudflare or Vercel, step by step.
Read part 4