I want to setup a single git repository that would work to build three different sites in Netlify. The code that powers each site would be the same (with a bit of configuration differences) but the content for each site would vary (the content being a bunch of markdown files). I thought perhaps I could setup the following structure
sites/ site_a/ post1.md post2.md etc... site_b/ post1.md post2.md etc... site_c/ post1.md post2.md etc... src/ index.html otherFilesAndTemplates.html etc.. netlify.toml package.json
With the above structure, I figured I could configure my build command via the Netlify UI to pass in the site I want to build as a query param so my build script would know which
sites/ folder to grab content from, i.e.
// build command for site a in netlify UI npm run build -- --site=a // build command for site b in netlify UI npm run build -- --site=b // build command for site c in netlify UI npm run build -- --site=c
Awesome, that gets me 95% of the way there. The one problem is CI. Because this is one git repository, but three different sites in Netlify, I don’t want to build all three sites every single time I make a change to the repo. I want each site to be able to check and say “if anything in
src/ or anything in this site’s folder changed, rebuild and deploy”. I thought I would be able to do this with
build.ignore, i.e. set an environment variable via the Netlify UI for each site and then do something like:
[build] ignore = "git diff --quiet HEAD~ HEAD src/ site/$SITE_ID"
But then I found this one little problem:
Using environment variables directly as values (
$VARIABLENAME) in your
netlify.tomlfile is not supported.
So my question is: is it possible to get a setup like what I described above? It’s kind of like a monorepo, but I don’t have a
package.json for every unique site. As mentioned, the code is the same for each site, it’s the content that changes. Is there a way to configure Netlify’s CI so that each site that links to the same git repo can check “hey, did anything in
src/ or my folder (be it
c) change? if so, then run a build and deploy. Otherwise, don’t do anything.”