Removing the repeated github username from the homepage url fixed the problem:

Correct value for "homepage":

"homepage": "https://myusername.github.io/myreponame"

Discussions

Code is deployed, but page is blank
Useful package, i already follow you instruction. But i got blank page node -v v9.7.1 npm -v 6.0.1 create-react-app --version 1.5.2 More on github.com
🌐 github.com
38
May 17, 2018
Blank page when deploying react site to github pages with custom domain name
Select Topic Area Question Body Hello. I'm trying to deploy this repo: https://github.com/oDragon/developer-portfolio to github pages with the custom domain name: chenlarry.com. Here are my DNS con... More on github.com
🌐 github.com
5
4
Blank Page after deployment
After, i git clone my repository ... i saw blank page. I tried everything and read the previous issues but could not find the solution. The website works in local. Which of these applies to you? (Select all that apply) I'm following the tutorial as-written from start to finish in link https://github.com/gitname/react-gh-... More on github.com
🌐 github.com
17
August 23, 2023
Blank Screen When Deploying React Site to Github Pages- No Error in Console
Select Topic Area Question Body Hello, I hope I am posting this in the right thread. I am a new front-end developer who has been learning React. I am having an issue where my React app which works ... More on github.com
🌐 github.com
1
2
August 13, 2023
🌐
GitHub
github.com › orgs › community › discussions › 62786
MY REACT PAGE IS SHOWING BLANK PAGE WHEN I GO LIVE ON GITHUB · community · Discussion #62786
I am facing some issues with deploying my React app on GitHub Pages. The app works fine locally, but when I access it on the live URL, I encounter two main problems: The page appears blank when accessed on GitHub Pages or via VS Code Live Server on my phone. In the browser console, I'm seeing multiple "Failed to load resource: the server responded with a status of 404 ()" errors for the JavaScript, CSS, and "manifest.json" files.
🌐
GitHub
github.com › gitname › react-gh-pages › issues › 3
Code is deployed, but page is blank · Issue #3 · gitname/react-gh-pages
May 17, 2018 - Useful package, i already follow you instruction. But i got blank page node -v v9.7.1 npm -v 6.0.1 create-react-app --version 1.5.2
Published   May 17, 2018
Author   adjieindrawan
🌐
GitHub
github.com › gitname › react-gh-pages › issues › 159
Blank Page after deployment · Issue #159 · gitname/react-gh-pages
August 23, 2023 - After, i git clone my repository in another PC and make some changes on the code and run "npm run deploy" i saw blank page. I tried everything and read the previous issues but could not find the solution. The website works in local. Cate...
Author   cap-oglu
Find elsewhere
🌐
GitHub
github.com › gitname › react-gh-pages › issues › 53
Deployed React website showing blank page · Issue #53 · gitname/react-gh-pages
January 19, 2021 - I deployed my website and it was working fine using the GitHub URL. Once I added my custom domain the website stopped displaying and is now a blank page. When I view page source it shows the index....
Author   mmont429
🌐
Reddit
reddit.com › r/react › github pages deployment using react app shows up as white screen with
r/react on Reddit: Github pages deployment using React app shows up as white screen with
August 25, 2022 -

I am trying to deploy my React app using Github pages using a custom domain that I own but I am unable to deploy it. I am stuck on what the issue is. I noticed that when I reload the page I am getting a repeat in my domain as an error, but unsure if this is the problem. My public website repository is available here https://github.com/ryanl35/react-website-ryan-1. Help is greatly appreciated. Thank you!

When loading the site After reloading
🌐
GitHub
github.com › orgs › community › discussions › 57102
Trying to load a react app into pages but the hosted site is just a blank white screen · community · Discussion #57102
You should look into how to fix the paths in the React build. I can't tell you how to do that, but probably setting some kind of base path/URL. 😉 · Beta Was this translation helpful? Give feedback. ... There was an error while loading. Please reload this page. Something went wrong. There was an error while loading. Please reload this page. ... Thank you. I appreciate the help.
🌐
Medium
medium.com › @landrykapela › bland-page-when-publishing-react-app-to-github-pages-f2fd8139c07d
Blank Page When Publishing React App to Github Pages | by Landry Kapela | Medium
April 3, 2019 - But confusing enough was that I could see the page title and favicon from my app, which gave me some peace of mind that at least I know my app is online but same time worrying where might the content have gone!!! This took me to using developer tools in Google Chrome browser, where I found out that some files were not being served, return in 404 error, which explained the blank page.
🌐
freeCodeCamp
forum.freecodecamp.org › t › deploying-react-app-to-github-pages-and-its-blank-white › 222680
Deploying React app to Github pages and it's blank white - The freeCodeCamp Forum
August 31, 2018 - Hello, I need some help to deploy my react app into github page. I’ve followed everything from https://github.com/gitname/react-gh-pages/tree/master my app successfully deployed by npm, my repo files on github are exactly the same from the example except for dependencies version in package.json, then I go to my site https://yohanesbawono94.github.io/react-app/ andd… as you can see it turns blank white.
🌐
Reddit
reddit.com › r/reactjs › what is my page blank for my github pages made with create-react-app when it is not on my local machine? i am at my wits end.
r/reactjs on Reddit: what is my page blank for my github pages made with create-react-app when it is not on my local machine? I am at my wits end.
February 20, 2019 -

Very frustrated, as this should be a simple task. Been at it for multiple days now and i feel very stupid. I followed just about every tutorial on the internet, but i feel like this is some sick joke. I am trying to deploy a functional website on github pages to work on a portfolio using react, but the page is blank. Every other tutorial out there seems to work just fine so i am missing something that everyone is leaving out of documentation.

here is where i am trying to launch my site https://akellergit.github.io/portfolio/, however as you can see, the readme.md is being shown instead of index.html....

so i tried https://akellergit.github.io/portfolio/public/index.html and the page is just straight up blank. the page is officially published and everything so there is no issue there.

Here is what the landing page looks like when running from lap top (at localhost:3000 ).

https://raw.githubusercontent.com/grommet/grommet-starter-new-app/master/public/cra-landing-page.png

Please, mighty ReactJS Gods, what am I doing wrong?

EDIT: here is the source for this super simple stuff https://github.com/AKellerGit/AKellerGit.github.io/tree/master/portfolio

Top answer
1 of 2
7

Never use BrowserRouter on GitHub Pages. There are some issues with it, it always shows blank screen. Use HashRouter instead, that will most probably work.

import { HashRouter } from "react-router-dom";

// some code here

return (
    <HashRouter base="/">
        <App />
    </HashRouter>
)
2 of 2
1

The create react app documentation says that:

GitHub Pages doesn’t support routers that use the HTML5 pushState history API under the hood (for example, React Router using browserHistory). This is because when there is a fresh page load for a url like http://user.github.io/todomvc/todos/42, where /todos/42 is a frontend route, the GitHub Pages server returns 404 because it knows nothing of /todos/42. If you want to add a router to a project hosted on GitHub Pages, here are a couple of solutions:

  • You could switch from using HTML5 history API to routing with hashes. If you use React Router, you can switch to hashHistory for this effect, but the URL will be longer and more verbose (for example, http://user.github.io/todomvc/#/todos/42?_k=yknaj). Read more about different history implementations in React Router.

Therefore you should use hashHistory if you want to host your site on GitHub Pages. Here is the link to documentation.

If you don't wish to change router, try deploying it on Netlify which is also another free hosting provider. But again for Netlify deployment, follow the documentation, which says:

To support pushState, make sure to create a public/_redirects file with the following rewrite rules:

/*  /index.html  200
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

🌐
Stack Overflow
stackoverflow.com › questions › 75860344 › react-app-deployment-on-github-pages-displays-a-blank-page
reactjs - React app deployment on GitHub Pages displays a blank page - Stack Overflow
The problem was that I had repeated my github username in the homepage url before the app name. Correct value for "homepage" is: myusername.github.io/myappname ... 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. ... 562 How to see an HTML page on Github as a normal rendered HTML page to see preview in browser, without downloading? 0 Issues deploying a routed React App to Github Pages
🌐
freeCodeCamp
forum.freecodecamp.org › t › blank-page-with-react-app-with-github-pages › 417115
Blank page with React app with github pages - The freeCodeCamp Forum
August 25, 2020 - Hey I keep getting a blank page with github pages. I have run npm run build and npm run deploy I still get a blank page. I have set a home page in my package.json . I am out of ideas. Can anyone help ?