Saturday, December 28, 2024
Google search engine
HomeGuest BlogsHow to Publish a Static Website on GitHub?

How to Publish a Static Website on GitHub?

Git is a free and distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. It is not only a great place to store and share our code with others but they also offer free web hosting of our HTML, CSS, and JavaScript projects.

Hosting a website enables many web users to access our web pages at the same time. If you want to run a website you need web hosting because unless you’ve got unlimited funds you would not be able to afford the web servers. GitHub has a lot to offer, it provides free hosting to your static website. To host the website via GitHub you’ll require a valid git account, the git software and all the codes and files of your static website.
In this article we’re going to learn how to host a static website on GitHub, let’s get started:

Step 1: Create / Sign into your GitHub account.

Step 2: Click on create a New Repository, give it a name and make sure to make it public.

Note : Please keep this Repository name handy we will require Repository Name while adding remote for pushing our code.

Step 3: Go to the directory where all the HTML files are present, right-click and select Git bash here which is going to open the command line.

Step 4: Give the command “git init” which will initialize a git repository.

Step 5: Give the command “git add .” which will add all the files into the repository.

Step 6: Now check the status of the repository by giving the command “git status“, if all the files are in green means the files are successfully stored in the repository.

Step 7: Give the command “git commit -m “my first commit” .” by which you give your first commit in git.

Step 8: Give the command “git remote add origin https://github.com/{yourGithubUserName}/{repoName from step2}.git” which would be the url given in your github id. This will add the remote origin to your local git repository.

Step 9: To push your code in repository give the command “git push -u origin master“, which is going to ask your username and password.

Step 10: Go to the GitHub page, click on your project and you can see all the files are pushed in the repository. Go to the setting and find GitHub Pages, in the source section from the drop-down menu select master branch save the changes.And your Site is successfully published, copy the url and open it in the new tab.

And yes!! your page is published at free of cost. Share the link of your page and it can be accessed by numbers of web users at the same time.

Last Updated :
22 Sep, 2023
Like Article
Save Article


Previous

<!–

8 Min Read | Java

–>


Next


<!–

8 Min Read | Java

–>

Share your thoughts in the comments

RELATED ARTICLES

Most Popular

Recent Comments