Different Netlify CLI sites under a folder

Hi there

I have a couple sites under my ‘dev/’ folder and recently ive began using more the ‘netlify deploy’ command.
Ive started making a mess, however, deploying one site instead of another. (as in: if today i deploy Site B, it will deploy to Site A ive linked yesterday)
Previously i thought the netlify site/id would be lionked to a particular folder but it seems perhaps not?

Been trying to figure out a way to set a ‘NETLIFY_SITE_ID’ and deploy it accordingly.
Anyone has an example to guide me?

thank you

Hey @bronze

When you run netlify link it the current directory (usually the project root) by first looking for a git repository or then by manually searching/entering a site.

So if you have multiple sites in a dev directory e.g.

dev
├── site1
└── site2

and each one is a different site, deployed to a different Netlify domain (e.g. site1.netlify.app, site2.netlify.app) then you will need to link each site/directory individually (i.e. cd site1, netlify link, cd ../site2, netlify link.)

that was what i thought would happen, yet when i link site2, it unlinks site1 from where it was and updates it
in effect i have only one link to netlify, no matter the folder
maybe my install borked?

I believe it is entirely the setup you have.

For instance, I have a projects directory. Inside that directory I have many projects that are individually linked to both Netlify (and GitHub.) Working in a specific directory I can deploy (or locally test) a site. If I am in the root projects directory, nothing happens because the directory is not linked to any Netlify site.

just did some detective work here, the root folder (my projects) was linked, maybe that was the problem
changing dirs and doing netlify status now seems to point everything to its correct place

This is likely the root cause.

1 Like

pun intended? i hope so.

Oh, a pun. I actually didn’t even realise! :rofl: :rofl: :rofl: :rofl:

1 Like