I've found the source of error. With this configuration you should have deploy from gh-pages branch:

Answer from Dmitry Malugin on Stack Overflow
🌐
DEV Community
dev.to › rashidshamloo › deploying-vite-react-app-to-github-pages-35hf
Deploying Vite / React App to GitHub Pages - DEV Community
April 15, 2023 - Change YOUR_REPOSITORY_NAME to the name of your GitHub repository. ... 🎉 You now have a gh-pages branch in your repository and your app is deployed (you can check it under Settings -> Pages ) P.S. To update your app deployment, just run the ...
🌐
GitHub
github.com › ErickKS › vite-deploy
GitHub - ErickKS/vite-deploy: Guide for vite react app deploy · GitHub
name: Deploy on: push: branches: - main jobs: build: name: Build runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v3 - name: Setup Node uses: actions/setup-node@v3 - name: Install dependencies uses: bahmutov/npm-install@v1 - name: Build project run: npm run build - name: Upload production-ready build files uses: actions/upload-artifact@v3 with: name: production-files path: ./dist deploy: name: Deploy needs: build runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' steps: - name: Download artifact uses: actions/download-artifact@v3 with: name: production-files path: ./dist - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./dist
Starred by 356 users
Forked by 67 users
Languages   CSS 51.2% | TypeScript 38.3% | HTML 10.5%
Discussions

Deploying First Vite Project on GitHub Pages
However, when I build and deploy my project for "gh-pages", a new branch is created which only contains a "dist" folder. Yes this is the intention. When deploying to Github Pages, the `gh-pages` branch is a "special" branch that just contains your build output so that Github Pages can read and serve it. More on reddit.com
🌐 r/reactjs
5
0
June 12, 2024
reactjs - Vite + react application: unable to deploy to github pages - Stack Overflow
With this configuration you should have deploy from gh-pages branch: ... Sign up to request clarification or add additional context in comments. ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... New site design and philosophy for Stack Overflow: Starting February 24, 2026... I’m Jody, the Chief Product and Technology Officer at Stack Overflow. Let’s... 4 Unable to deploy my React App to GitHub ... More on stackoverflow.com
🌐 stackoverflow.com
reactjs - Blank page when deploying a react app to github pages and vite - Stack Overflow
The page I am trying to deploy is here: LINK I don't know if it matters but I am currently using the free domain given to me by GitHub: www.elvas.me · I tried following the react official docs: Link, but it didn't work for me... Perhaps it's because I am using vite and not create-react-app? More on stackoverflow.com
🌐 stackoverflow.com
Deploying a Vanilla React App w Vite tooling to GitHub pages
Necessary? No. But it makes things braindead simple, and it'll work automatically on pushes to github. It's alot less work and alot harder to break than the alternative of manual uploads of builds https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site I haven't run the build command in years, but it just works once you say "hey deploy the page whenever main changes please" More on reddit.com
🌐 r/reactjs
3
0
January 30, 2025
🌐
GitHub
github.com › sitek94 › vite-deploy-demo
GitHub - sitek94/vite-deploy-demo: Deploy Vite app to GitHub Pages using GitHub Actions · GitHub
This is happening, because of the subdirectory-like URL structure GitHub uses for Project Pages. Asset links are referencing the files in the domain root, whereas our project is located in <ROOT>/vite-deploy/demo. This is how the links should look like: ❌ Bad https://sitek94.github.io/assets/favicon.17e50649.svg ✅ Good https://sitek94.github.io/vite-deploy-demo/assets/favicon.17e50649.svg · Fortunately, there is a very easy fix for this. Add the following line in vite.config.js: import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], + base: '/vite-deploy-demo/' })
Starred by 383 users
Forked by 54 users
Languages   JavaScript 52.8% | CSS 34.4% | HTML 12.8%
🌐
Medium
medium.com › @devxprite › how-to-deploy-vite-react-app-to-github-pages-00e150f73961
How to deploy Vite React App to GitHub Pages | by Prateek Singh | Medium
April 29, 2024 - How to deploy Vite React App to GitHub Pages You can use GitHub Pages to host your website for free. In this guide will show you how you can deploy your Vite React applications to GitHub Pages in an …
🌐
Medium
medium.com › @aishwaryaparab1 › deploying-vite-deploying-vite-app-to-github-pages-166fff40ffd3
Deploying Vite Deploying Vite App to GitHub Pages | by Aishwarya Parab | Medium
July 12, 2023 - import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], base: "/book-landing-page/" }) Install gh-pages package as a dev dependency.
🌐
Reddit
reddit.com › r/reactjs › deploying first vite project on github pages
r/reactjs on Reddit: Deploying First Vite Project on GitHub Pages
June 12, 2024 -

Hello, I'm creating a simple Note Recorder app with Vite. As many people suggest, I'm trying to track my project with Git and Github. My repository is working fine and I learned how to push recent changes.

However, when I build and deploy my project for "gh-pages", a new branch is created which only contains a "dist" folder.

Is it a good practice to have a "main" branch for inspecting my code as it is originally structured and a "gh-pages" (or whatever name) branch for deploying it?

The purpose of all this is having a portfolio on my resume so recruiters can take a look. This project is simple and uses Local Storage. I want to add more projects in the future using other tools such as Nextjs and a Mongo or Postgres database.

Find elsewhere
🌐
GitConnected
levelup.gitconnected.com › deploy-your-vite-app-to-github-pages-a-lazy-devs-guide-37b0b472fa35
Vite to live in 5 minutes! The Lazy Dev’s Guide to GitHub Pages | by Deepak Surya | Level Up Coding
April 2, 2025 - import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; export default defineConfig({ plugins: [react()], base: "/my-vite-site/" }); ... This package handles deployments for you.
🌐
YouTube
youtube.com › watch
Deploy Vite React App to GitHub Pages (2025) - YouTube
Looking to deploy your Vite React app to GitHub Pages? This video provides a clear, step-by-step guide to get you started! Learn how to configure your projec...
Published   April 27, 2024
🌐
GitConnected
levelup.gitconnected.com › deploying-a-vite-react-typescript-app-to-github-pages-using-github-actions-jest-and-pnpm-as-a-a3461ef9c4ad
Deploying a Vite React TypeScript app to Github Pages using GitHub Actions, Jest, and pnpm— As a pro | by Jonatan Kruszewski | Level Up Coding
July 23, 2024 - Settings > Pages: Build and deployment to Github Pages is done from “GitHub Actions” ... After creating the repository, create the project locally and link it to the remote. I will use pnpm as my package manager and run the react-ts template ...
🌐
DEV Community
dev.to › pedrotech › how-to-deploy-a-vite-react-app-to-github-pages-4j3k
How to Deploy a Vite + React App to GitHub Pages - DEV Community
December 13, 2024 - Install gh-pages From your project directory, run: ... { "name": "my-vite-react-app", "homepage": "https://<your-username>.github.io/<repo-name>/", "scripts": { "dev": "vite", "build": "vite build", "predeploy": "npm run build", "deploy": "gh-pages -d dist" } }
Top answer
1 of 8
13

I see that you have managed to deploy your React project to Github pages successfully, but here is how I did it in case anyone needs help:

  • First things first, make sure that your ".git" folder and your project are in the same folder.

  1. Run npm run build. You should have a dist folder now.
  2. Open the file vite.config.js (or .ts).
  3. Add the base file with your repository name. Include the two /.

Example: let's say your github project's URL is https://github.com/atlassian/react-beautiful-dnd.

export default defineConfig({
  base: "/react-beautiful-dnd/",
  plugins: [react()],
});
  1. Open your .gitignore file and delete the dist line from it. You want to make sure that the dist folder is pushed to github.
  2. git add .
  3. git commit -m "deploy"
  4. git subtree push --prefix dist origin gh-pages
  5. Wait for a couple minutes (in my case it took 4 minutes) and open the page. In the example above, the URL would look like this: https://atlassian.github.io/react-beautiful-dnd

In case it's still showing a blank page, it's very likely to do with the step number 3. Ensure you added the correct repository URL and that it begins and ends with the / sign.

That is about it, I hope it helps. I used this blog post for guidance, it is a more detailed explanation of the above.

2 of 8
12

Ok, so to solve this the only thing that I had to do was to add base:"{repName}" to the vite.config.ts file.

Source: https://vitejs.dev/guide/static-deploy.html

The images were not loading, I used this to fix them: Github pages vite JS build not showing the images

🌐
Medium
medium.com › @badreddine.boudaoud21 › create-a-react-app-with-vite-and-deploy-it-on-github-48b82e19f821
Create a React app with Vite and deploy it on GitHub | by Badreddine Boudaoud | Medium
February 11, 2024 - Since this project is a React project, you need to select React from the list. ... After the dependencies are installed completely, you need to install ‘gh-Pages’ package. ... The ‘gh-pages’ package uses the homepage field in the package.json file to determine where to deploy your app. To update the package.json file, follow these steps: 1. Add a homepage field with the URL of your GitHub repository in the following format:
🌐
DevGenius
blog.devgenius.io › how-to-deploy-your-vite-react-app-to-github-pages-with-and-without-react-router-b060d912b10e
How to Deploy Your Vite React App to GitHub Pages (With and Without React Router) | by Fitrahtur Rahman | Dev Genius
November 8, 2023 - ... The source code of this guide can be found here. This method is only for those who want to deploy their Vite React app to https://<OUR_GITHUB_USERNAME>.github.io/<REPO_NAME>/ path.
🌐
DEV Community
dev.to › shrinivasv73 › how-to-deploy-reactjs-apps-built-using-vite-on-github-pages-38bi
How to deploy ReactJS Apps (built using Vite) on GitHub Pages? - DEV Community
December 26, 2025 - This field is particularly important when deploying a React application to GitHub Pages or any other static site hosting service that serves the site from a subdirectory. Do update the values of <username> and <repository> of the homepage property. In my case the values are ShrinivasV73 and Deploy-ReactJS-App-With-Vite respectively.
🌐
LinkedIn
linkedin.com › pulse › deploying-react-vite-application-mangesh-ahire-p6auf
Deploying a React + Vite application
February 17, 2024 - First, install gh-pages as a dev dependency: ... Finally, go to your GitHub repository's settings page, scroll down to the GitHub Pages section, and configure it to use the gh-pages branch as the source for your GitHub Pages site.
🌐
YouTube
youtube.com › pedrotech
How To Deploy A React Vite App To Github Pages (Simple) - YouTube
In this video I will teach you guys how to deploy a vite react app to github pages in order to see your projects live.Shoutout to the template I used: https:...
Published   November 21, 2024
Views   6K
🌐
Medium
nikujais.medium.com › deploy-your-vite-react-app-on-github-pages-b52b2ad1edd2
Deploy your Vite + React app on GitHub Pages | by Nikita Jaiswal | Medium
October 17, 2025 - Update the base field to include your repository name: import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], base: '/your-repo-name/', // 👈 important for GitHub Pages })
🌐
DEV Community
dev.to › dwtoledo › deploying-a-vite-app-on-github-pages-using-github-actions-with-github-secrets-1hn0
Deploying a Vite app on GitHub Pages using GitHub Actions with GitHub Secrets - DEV Community
August 10, 2024 - A page to create your own workflow will open. On this page... Name the new workflow as "deploy.yml". ... Open the "Deploying a Static Site" Vite Guide on https://vitejs.dev/guide/static-deploy and look for GitHub Pages session.