0
0
Firebasecloud~10 mins

Multiple site hosting in Firebase - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Multiple site hosting
Start: Prepare sites
Create firebase.json config
Add hosting targets for each site
Run firebase deploy
Firebase uploads each site
Sites available at different URLs
Users access sites separately
This flow shows how you prepare multiple sites, configure them in Firebase, deploy, and then access each site at its own URL.
Execution Sample
Firebase
firebase init hosting
firebase.json with multiple targets
firebase deploy --only hosting:site1,hosting:site2
This sequence initializes hosting, configures multiple sites, and deploys them to Firebase.
Process Table
StepActionInput/ConfigResultNotes
1Initialize Firebase Hostingfirebase init hostingHosting setup files createdPrepares project for hosting
2Edit firebase.json{ "hosting": [{"target": "site1", "public": "site1"}, {"target": "site2", "public": "site2"}] }Multiple hosting targets definedConfigures multiple sites
3Deploy sitesfirebase deploy --only hosting:site1,hosting:site2Site1 and Site2 uploadedDeploys both sites in one command
4Access sitessite1 URL and site2 URLEach site loads separatelyUsers see different content per site
5ExitAll sites deployedDeployment completeNo errors, hosting active
💡 All sites deployed and accessible at their respective URLs
Status Tracker
VariableStartAfter Step 2After Step 3Final
firebase.jsonempty or defaultconfigured with multiple hosting targetsunchangedconfigured with multiple hosting targets
hosting targetsnonesite1 and site2 definedsite1 and site2 deployedsite1 and site2 deployed
deployment statusnot deployednot deployeddeployeddeployed
Key Moments - 3 Insights
Why do we need to specify multiple hosting targets in firebase.json?
Because each site needs its own configuration to tell Firebase where its files are and how to serve it. See execution_table step 2.
Can we deploy multiple sites with one command?
Yes, using 'firebase deploy --only hosting:site1,hosting:site2' deploys all specified sites at once. See execution_table step 3.
How do users access different sites after deployment?
Each site has its own URL or subdomain configured by Firebase, so users visit different addresses to see each site. See execution_table step 4.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the result after editing firebase.json in step 2?
ASites deployed
BMultiple hosting targets defined
CHosting setup files created
DUsers access sites
💡 Hint
Check the 'Result' column in step 2 of execution_table
At which step are the sites actually uploaded to Firebase?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look for 'uploaded' or 'deployed' in the 'Result' column
If we only deploy hosting:site1, what happens to site2?
ASite2 remains unchanged and not updated
BSite2 is also deployed automatically
CSite2 is deleted
DDeployment fails
💡 Hint
Refer to deployment command in execution_sample and step 3 in execution_table
Concept Snapshot
Multiple site hosting in Firebase:
- Define multiple hosting targets in firebase.json
- Each target points to a different folder
- Deploy multiple sites with one command
- Each site gets its own URL
- Users access sites separately
Full Transcript
Multiple site hosting in Firebase involves preparing each site folder, configuring firebase.json with multiple hosting targets, and deploying them together. The process starts by initializing hosting, then editing firebase.json to add each site as a target with its own public folder. Deployment uploads all specified sites, making them available at separate URLs. Users can then access each site independently. This method allows managing multiple websites under one Firebase project efficiently.