🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
Astro Themes••By Komal Nakrani

Update an Astro Theme Without Losing Your Edits

How to update an Astro theme you bought without losing edits: keep changes in config and content, merge releases on a branch, resolve conflicts and test the build.

#Astro#Update Astro Theme#Astro Themes#Git

To update an Astro theme without losing your edits, keep the theme’s original repository connected to your project as a Git remote, make your changes on your own branch, and merge each theme release into that branch, resolving conflicts only where you and the theme edited the same lines. Before merging, read what changed, and after merging, run npm install, npm run build and a quick visual check before you deploy. If you put your changes in config, content and design tokens instead of rewriting theme components, most updates merge with no conflicts at all.

Key Takeaways

  • Updates are just commits. Git can combine them with your edits as long as both histories are connected.
  • Put brand, copy and settings in config and content files; edit components only when you must.
  • Always update on a separate branch, then build and preview before merging to main.
  • Read the theme’s changelog or diff first, especially for Astro major version upgrades.
  • If you started from a zip or copied files, you can still update by diffing two theme versions.

What a theme update contains

Before you plan an update, it helps to know what tends to change between theme releases:

Change type Example Risk of conflict with your edits
Dependency bumps astro, @astrojs/*, Tailwind CSS in package.json Low, unless you added packages too
Astro upgrade fixes Config changes, renamed APIs, new content config Medium; touches shared files
Bug fixes Mobile menu, focus styles, broken link Low to medium
New pages or sections An extra page layout or component Low; new files rarely conflict
Design changes Spacing, typography, colours High if you restyled the same components

The pattern is clear: new files merge cleanly, and edits to the same lines conflict. Your goal is to keep your changes away from the lines the theme is likely to touch.

Set your project up for painless updates

The best time to make updates easy is before you change anything. Two habits do most of the work.

Keep the theme as a remote

If you bought a theme delivered as a private GitHub repository, as Komal Nakrani themes are, clone it and keep its history. Then point origin at your own repository and keep the theme as upstream:

# Terminal
git clone [email protected]:theme-author/your-theme.git my-site
cd my-site
git remote rename origin upstream
git remote add origin [email protected]:your-name/my-site.git
git push -u origin main

Now git fetch upstream brings in theme releases, and git push sends your work to your own repo. The Git upstream remote tip walks through this setup step by step. Our getting started docs show the clone and install commands for a purchased theme.

Put your changes where updates won’t reach

Most of what makes a theme “yours” can live outside its components:

  1. Site settings (name, navigation, social links, contact details) in the theme’s config file, often src/config.ts or src/site.config.ts.
  2. Copy and posts in content collections under src/content/.
  3. Colours, fonts and spacing in CSS custom properties or the Tailwind CSS config.
  4. Images and logos in src/assets/ and public/.
  5. New components in your own folder, such as src/components/site/, rather than edits to existing theme components.

When you do need to change a theme component, consider copying it into your own folder and pointing the page at the copy. Future fixes to the original won’t reach your copy, but they won’t conflict with it either. Our guides to customizing an Astro theme and theme site config show where these files usually live.

Update an Astro theme step by step

With the remotes in place, an update is a short, repeatable routine.

1. Start clean

git status            # should print "nothing to commit"
git checkout main
git pull origin main

Commit or stash any work in progress first. Merging into a dirty working tree mixes your unfinished changes with the theme’s.

2. Fetch and read the changes

git fetch upstream
git log --oneline main..upstream/main     # commits you don't have yet
git diff --stat main...upstream/main      # files the theme changed

The three-dot diff shows what changed in the theme since the point your branch left it, which is what you’ll be merging. Look for package.json, astro.config.mjs and src/content.config.ts in the list; changes there deserve a careful read.

3. Merge on a branch

git checkout -b theme-update
git merge upstream/main

If Git reports no conflicts, skip to testing. If it stops with conflicts, the next section covers them.

4. Reinstall and build

npm install
npm run build
npm run preview

npm install picks up dependency changes from the theme’s package.json and lockfile. A successful npm run build means content schemas, imports and pages still compile. Then open the preview and click through the pages you customised most.

5. Merge and deploy

git checkout main
git merge theme-update
git push origin main

Your host deploys from main as usual. If something slipped through, git revert on the merge commit undoes the update in one step.

Resolve merge conflicts

A conflict means you and the theme changed the same lines. Git marks them in the file:

<<<<<<< HEAD
  --color-primary: #0f766e;
=======
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
>>>>>>> upstream/main

The top half is yours, the bottom half is the theme’s. Here the right answer keeps your colour and the theme’s new variable:

  --color-primary: #0f766e;
  --color-primary-hover: #0d5f59;

A few rules make conflicts quick to settle:

  • Lockfiles: don’t edit by hand. Take the theme’s version with git checkout --theirs package-lock.json, then run npm install to add back any packages you added yourself.
  • package.json: keep both sides’ dependencies, and take the theme’s version numbers unless you upgraded something deliberately.
  • Content files: keep yours. The theme’s demo content is rarely something you want back.
  • Components you edited: read the theme’s change, then reapply it to your version by hand if it fixes something you care about.

After resolving, git add the files and run git commit to finish the merge. Then build and preview as in step 4.

When the update includes an Astro upgrade

Theme updates often carry an Astro version bump, and major versions can change config options and APIs. Before merging one:

  1. Check which Astro version the update moves to in package.json.
  2. Check your Node.js version. Current Astro 7 releases need Node.js 22.23.4 or newer, and your host’s build image needs it too.
  3. Read the official Astro upgrade guide for the major version, and search your own code for anything it lists as removed or renamed.
  4. Run npx astro check after the merge to catch type errors in your own components.

Code you wrote yourself, such as a custom page that uses a deprecated API, won’t be fixed by the theme update. The build error usually names the file and the fix. Our Astro major version upgrade guide lists the common breaking changes.

If you didn’t keep the theme’s history

Maybe you downloaded files, copied the theme into an existing repo, or squashed everything into one commit. Git can’t merge histories it can’t connect, but you can still update:

  1. Get the version of the theme you originally started from, and the new version.
  2. Make a patch of what changed between them:
# Terminal, in a clone of the theme repository
git diff v1.2.0 v1.3.0 > ../theme-update.patch
  1. Apply it to your project and review what didn’t apply cleanly:
# Terminal, in your project
git apply --3way ../theme-update.patch
git status

--3way falls back to a three-way merge where it can and leaves conflict markers where it can’t. If the theme doesn’t tag releases, use the commit hashes instead of tags. After this one-time catch-up, consider reconnecting the histories so future updates are a normal merge; the upstream remote tip covers that case.

Decide whether to update at all

Not every release is worth merging into a finished site. Updating makes sense for security fixes in dependencies, bug fixes you’ve noticed, and Astro upgrades you’ll need eventually. It’s reasonable to skip purely cosmetic changes on a site whose design you’ve already made your own.

If you skip updates for a long time, merge them in steps rather than jumping a year of changes at once. Merge one release, build, then the next. Small merges have small conflicts.

Komal Nakrani themes come with free lifetime updates delivered through the same private repository, so the routine above works for every release. If you’re still choosing a starting point, you can browse Astro themes and preview each one before you buy.

FAQ

How do I update an Astro theme I already customized?

Keep the theme repository as a Git remote named upstream, then run git fetch upstream and git merge upstream/main on a new branch. Resolve any conflicts, run npm install and npm run build, preview the site and merge the branch into main.

Will updating my Astro theme overwrite my changes?

Not if you merge with Git. A merge combines the theme’s changes with yours and only stops where both changed the same lines, so you decide what to keep. Copying new theme files over your project, on the other hand, does overwrite your edits.

How do I avoid merge conflicts when updating a theme?

Keep your changes in config files, content collections, CSS variables and your own components instead of editing the theme’s components. New files and content rarely conflict, and theme updates mostly touch components and dependencies.

Do I need to update Node.js when my Astro theme updates?

Sometimes. If the update raises the Astro version, check its required Node.js version. Current Astro 7 releases need Node.js 22.23.4 or newer, both on your machine and in your host’s build settings.

Can I update a theme I downloaded without Git history?

Yes. Create a patch between the old and new theme versions with git diff, then apply it to your project with git apply --3way. Review anything that didn’t apply cleanly, then build and preview as usual.