Deploy a React App as a Github User Page with Yarn

JavaScriptErika on May 29, 2018

tldr; see Solution I've been working on redoing my portfolio site, it's still a WIP - that being said here it is so far. I need to polish my por... [Read Full]
markdown guide

Great article.

When using react-router, have you tried adding a redirect, from '/repository-name' to '/home' to solve the final issue?


I have tried this and it works. add <Route exact path="/your-github-repo" render={() => <Redirect to="/" />} /> to your routes



Yesterday I got the idea that I'd replace my old Jekyll based personal GH-page with React site built with GatsbyJS. Unfortunately I forgot the whole point with version control and deleted the old site's repository before building the new one. I ended up not liking Gatsby, so currently I have no site. So, yeah, this is couldn't have come at a better time.




Haha, I did the same thing with my previous user page; I deleted my repo, and started fresh (with my current project) as I had to do something super wonky with the build files with my previous setup (I really had no idea what I was doing at the time)!

I definitely feel confident with this method now, especially for any needed updates or complete redesigns in the future.


I did some digging around, here's what I found for vue:



^ This method appears to be the most straightforward for vue, as you don't need to add any dependencies. I'd still recommend creating a source branch as you'd be pushing your build files directly to master.


I would imagine every framework will work which builds everything into HTML, CSS and JS files; you are manually building it when pushing it to master.

I am not familair with Vue (at least, haven't tried it) but I would imagine it is quite a similar process as you are essentially building the proper files.


Hi, thanks for writing this tutorial!

I followed the instructions but I'm still getting an error after running deploy from the source branch.

'fatal: A branch named 'master' already exists.'

Do you have any idea why?


Never mind , I managed to get it work. Thanks again for the instructions! :)


I am having the exact same problem right now but I could not get it work. Could you please share how did you solve it?

EDIT: for anybody who would face the same problem: refer here

I could not solve this problem so I came up with another solution: -check out a new branch called "source" which is an exact copy of "master".
-deploy the site to branch "gh-pages" with usual gh-pages npm module. (I use npm in my example, but the script is same.)

  • rebase "master" to "gh-pages" and simply push it. So "master" will have what "gh-pages" will have.

It is a not a clean solution though. Any feedback is much appreciated.


This was really helpful.! I've been trying to add a custom domain name to my repo. This article saved at least me a couple of hours. However, I don't understand why we need to be in source to run build?


You're awesome!! Thank you for posting this tutorial! I've been fighting with this and you cleared it up, and made it make sense. Thanks again!


Hey thanks. This saved me pulling my hair and digging over google only to find solution for project sites.


I absolutely needed this. I learned (the hard way) that directly connecting the app to GitHub was a mistake. Thank you for this!


You're welcome - thank you for your feedback!!! I got hung up on it after working on my portfolio and wanting to test it out - it was frustrating because it didn't feel like there was cohesive documentation out there and I wanted to fix that problem! :)


Great post! I was looking for a tutorial on how to do this just now. Thanks!


Awesome - thank you so much!
I JUST updated the article to hopefully save some people some time if you are using React Router and deploying as a user page! Cheers to a successful deploy!


Great post, I was having a bit of trouble with this myself, really helped me out :)


Struggled with that a lot, now it works!
Thank you!


Excellent article! Worked on the first try for me.


Awesome! Thanks for being easy to understand, direct and thorough. Will be sharing.

code of conduct - report abuse