Prerequisites: folder with content you want to host (HTML files, images etc.) e.g. d:\mysite
Host your site on Firebase server
- prepare the content for hosting by moving all files to subfolder
public
- create subfolder
public
- move all files to the subfolder
- create subfolder
- if you don’t have a Google account (does not have to be tied to Gmail address - click on ‘Use my current email address instead’) sign up for one
- sign up for Firebase here
- install npm
- open command prompt
- e.g. press windows key
- type ‘command’
- press Enter
- install Firebase tools
- in command prompt execute
npm install -g firebase-tools
- in command prompt execute
- connect your machine to Firebase
- execute
firebase login
- execute
- open command prompt in the folder with your website e.g.
d:\mysite
- one way of accomplishing this would be to navigate to folder in Windows Explorer and type
cmd
in the address bar
- one way of accomplishing this would be to navigate to folder in Windows Explorer and type
- run
firebase init
command- answer Yes by pressing Enter
- select Hosting
- moving down with arrow keys
- press space
- press Enter
- select
[create a new project]
- press Enter
- when asked about public directory, just press Enter
- when asked about single-page app, just press Enter as you probably have an ordinary site
- when (if) asked to overwrite index.html, just press Enter as you do not want to overwrite your content
- now go to Firebase console to create a ‘project’ for your site
- click on Add project
- enter a name for your project
- take note of project id
- check both checkboxes, or uncheck both to enable Create project button
- click the Create project button
- now go back to console window
- type
firebase use --add
- your newly created project should be the only item in the list
- press Enter
- when asked about alias, type in
production
- press Enter
- type
- enter
firebase deploy
and wait a few seconds- you are notified that you site is available at https://mysite-project-id.firebaseapp.com
Now, whenever you make modifications to your web site
- open command prompt in
d:\mysite
- execute
firebase deploy
Connect your domain name to the web site
If you have a domain name, there are a few additional steps that need to be done.
- go to Firebase
- click on your project
- click on hosting on left-hand side
- click on ‘Connect domain’ button
- enter domain name in the appropriate edit box
- click on ‘Continue’
Here it gets a bit tricky. Firebase will provide a string of text that needs to be set in a new TXT DNS record for your domain.
- go to DNS control panel for your domain, or otherwise set the TXT record
- click on ‘Verify’ in Firebase console
- if not successful, appropriate message will be displayed
- try waiting a couple of minutes as these settings need time to propagate
- when you succeed in verifying domain ownership you’ll need to add two more DNS records for your domain
- again, this might take some time to start working
Error messages in Firebase console regarding this part of procedure are a bit vague and sometimes plainly misleading. So don’t give up if you don’t succeed the first time. Verify that records in the DNS control panel are same as Firebase needs them to be. Verify that you do not have any extra CNAME or A records left over from before that might interfere with new config. Try everything once more. Try to delete connection to domain and then try again. Try to use Advanced setup for connecting the domain instead of Basic setup.
Conclusion
With this, you get your own web site with your own domain with support for HTTPS which is more important every day since browsers tend to mark plain HTTP sites as ‘insecure’.