Basically, static sites and project websites are hosted with github. If you want to host any blog sites then you can do with Jekyll too. Check my other posts for Jekyll.
To host any site, I am explaining here from Linux platform, you can use same method for windows too. follow these steps:
You can watch this video or follow the instructions below.
- login to your github account and create a new repository
- in terminal navigate to your website’s folder (where index.html is located)
- run the following github commands:
git init git add . git commit -m "your message here"
- now lets add the remote origin from github
git remote add origin https://github.com/lakshmanbasnet/test.git
** replace lakshmanbasnet with your username ** replace test.git with your repository name
Your Gift of $200 Cloud Hosting Credit is Here. Claim Now!
- the default branch is master, for hosting websites with Github we need to push our files to gh-pages branch. Remember you need to push to this branch since any files pushed to master branch won’t be generated for websites, if you push to gh-pages branch, github will automatically generate website for you.
- lets make new branch gh-pages with command:
git branch gh-pages
- lets navigate to our gh-pages branch
git checkout gh-pages
- now every thing is ready, just hit push command and enter your credentials when asked
git push origin gh-pages
- after you have pushed your file to github repo, goto your github repo in your browser
- in settings scroll down to find the link for your website, the link will be something like https://lakshmanbasnet.github.io/test/
- congratulations your site is live now
- to make any changes to the website, you need to push the files from your computer to github by following commands:
git add . git commit -m "your update message" git push origin gh-pages
To add custom domain name to replace the default domain name provided by github check my next post.
Thanks! Enjoy free hosting!! 😉