Duplicating a Stackbit site is a manual process. The steps below will be sufficient for the average site. You may need to adjust based on your individual requirements.
In general the process looks like this:
- Create a new site
- Transfer the repo to your GitHub account
- Locally duplicate the existing project
- Commit and push
The first step is the easy part — create a new Stackbit project. Select any theme.
The generated code will eventually be replaced, so it doesn't matter where you start.
After you're new site is up and running with Stackbit, transfer the code to your GitHub account. This will create a new repo with the new site's code.
Next, you'll want to replace the new repo's code with your existing code. This can be done a number of ways. What we've provided here is the safer method.
First, clone the new site — the one that Stackbit just transferred to your GitHub account. Your new project will have a default branch (
main) and a
preview branch, which is the branch used by the Stackbit application. Check out your
git clone [EXISTING_GITHUB_REPO_URL] cd [REPO_NAME] git checkout preview
Now, the fun part! Delete every file in your repo. And commit the change. (Don't push yet!)
git add . git commit -m "Delete everything!"
Next, add into your project all the code from your existing site. Commit the changes to the
git add . git commit -m "Duplicate existing site"
Now that your code looks good locally, you can update Stackbit by pushing.
Push these two commits to the
Stackbit now needs to check and install new dependencies and restart your preview server. It can take some time for the changes you pushed to be reflected in Stackbit.
When everything looks good in Stackbit, that means your
preview branch is in good shape and you're ready to go. You're ready to publish. Doing so will merge your
preview branch into
main and update your live site.
Since you already have the code locally, you're also welcome to merge
main manually and push
main to GitHub. This will automatically trigger a redeploy of your site.