DEV Community

Cover image for Deploy create-react-app to github pages adventure
Alina Osv
Alina Osv

Posted on

Deploy create-react-app to github pages adventure

This year I promised myself to create my own webpage. Without thinking twice I decided to host my website at github with some constraints:

  • source code should be placed at the same repo
  • website should be hosted as user page (from root folder)

Looking for a deploy guide I figured out, that github allows to publish user page only from default branch (master) & doesn't allow to set custom folder as root for deployed website. Ooops πŸ˜₯

A quick research gave me 3 options:

  • deploy website as project (but I wish a pretty url πŸ₯Ί)
  • leave in repo just the final build (and how to deal with the source code?! 🧐)
  • move source files to submodules (why so difficult πŸ™ˆ)

Messing around for a while and almost decided to choose the submodules option, I came across the official guide to deploy create-react-app. Last step reminded to directly setup deploy branch (master in common).

That's it! We could place source code into different branch and use master branch as build folder. So I moved the source code into dev branch & finally deployed my page.

Hope this trick will help you to save couple of hours and deploy your user page without painπŸ˜‰

Top comments (0)