menu
Channels
Team

Deploy multiple sites using a gatsby theme on netlify

July 22, 2019 at 10:33am

Deploy multiple sites using a gatsby theme on netlify

July 22, 2019 at 10:33am (Edited 1 year ago)
I'm not sure if this was discussed before but I'm trying to deploy on netlify a monorepo that's using yarn workspaces. (I don't want to publish the theme at the moment)
I have the following structure:
  • node_modules
  • packages
    • my_gatsby_theme
  • sites
    • first_site
    • second_site
    • third_site
  • package.json
Each site is using the theme inside the packages folder. In order to build each site I'm suppose to run yarn workspace first_site build and the same command for the other two sites. In package.json I can set up a global build command that will run all 3 build scripts for each site but what I don't know is what publish directory should I set in netlify since it's not a single site?
I'm kind of new to this whole setup with yarn workspaces and netlify, maybe I'm doing it wrong. Should I make a separate repo for each site instead?

July 22, 2019 at 2:36pm
My hunch (which I haven't tested, please know) is that you'd configure 3 separate Netlify sites... configure all 3 to trigger a deploy when you commit to your repository... configure them each with different public directories and (if necessary or useful) with their own build command.
  • reply
  • like

July 26, 2019 at 6:06am
Yea, that's what I ended up doing. Thanks for replying!
  • reply
  • like

July 30, 2019 at 2:00pm
Mmm... but when you do a commit for the first_site the other one trigger e build too?
I'm using yarn workspaces too but then I think to use git submodules for my sites only and manage each one with its own repo.
  • reply
  • like
Mmm... but when you do a commit for the first_site the other one trigger e build too?
I'm using yarn workspaces too but then I think to use git submodules for my sites only and manage each one with its own repo.
Hi Marco,
Another way to think of it is that code is committed to the repo. (Not to the first_site.) Each site at Netlify is simply listening for new code at GitHub -- when a push is made to the GitHub repo, every Netlify site listening to that repo will trigger a deploy for itself.
Each site at Netlify can have unique deploy commands and 'public' directories. Perhaps can explain more about this solution?
  • reply
  • like
Because you would like to update all the sites together right? In fact I'm thinking how build each site separately but if I made an update to the common theme is right that all the websites update together :-P Thanks ;-)
  • reply
  • like