The challenges associated with developing your first website are numerous. There are many stages and specifics to take into account. So, a lot of students get lost when it’s time to present their first project.
Today, a writing essay service can solve a lot of problems students deal with. Yet, such services can’t write a code for you or host a website. You will have to do it yourself. Fortunately, we can help.
The details to take into account can be quite scary and unclear at first. If you are not used to working in a terminal, you will make typos in commands or forget to include some symbols, but it’s okay. Be sure that after you publish 2-4 websites, you will do it blindly. All you need is practice.
Meanwhile, you can order an essay on another subject to dedicate your full attention to hosting your website correctly. So, let’s go through the steps you need to perform to publish your website successfully!
Create a Repository on GitHub
For a basic website, all you need to do is:
- choose the repository name without using capital letters, spaces, or any symbols except hyphens;
- indicate whether you need a public or private repository – a public one is more than enough; if you need to hide your data, there’s a 2-week free trial for publishing such a website, but you will need to pay sooner or later;
- add a README file if you want to introduce your project to the users in detail;
- add a .gitignore file – the type Node is the most suitable for web development; however, you can also create a custom file in your text editor;
- to make sure your open-source code is used correctly by others, choose a license depending on your needs.
Add the Remote Repository to Your Local One
If you still haven’t done it but already initiated a local repository, you probably work in a terminal and not GitHub Desktop. So, follow the next steps:
- Make sure you don’t have existing remote branches by typing in the command: git remote -v. If there are two links for fetching and pushing the repository, skip the section.
- Go to your remote GitHub repository, click on the ‘Code’ button and copy the SSH URL. If you don’t have the SSH key, install it according to the detailed guide from GitHub or copy the HTTP URL.
- Go back to the terminal, type ‘git remote add [name of your project without spaces] [HTTP/SSH URL]’ and press enter. It’s recommended to use the generally accepted name of any project, which is ‘origin’.
- Repeat step one to make sure you added the repository.
Prepare Your Project For Push
First of all, make sure you have an index.html file placed at the root of the project. Before you make the push, check whether all the changes are saved and whether you’re on the right branch. If you have several and your project is good for now, it’s better to merge all the branches with the main one. To do it, perform the following steps:
- Type in ‘git status’ to check what data was saved.
- If there are lines highlighted in red and the terminal says that there are changes that were not staged for commit, type in ‘git add .’ and then commit the changes.
- If there is green text with changes to commit, go straight to typing’ git commit -m [your comment about this commit]’.
- Switch to the main branch by using the command: git checkout main (or master).
- Type ‘git merges [name of the secondary branch, or the one you switched from]’. In case there are more secondary branches, repeat the operation for each of them.
- There is a possibility that conflicts in data will arise. So, the problematic files will be highlighted in the text editor, and you will have to choose what part of the code you should leave. After you clear the conflicts, repeat steps 2-3.
Push Your Repository to GitHub
Type in ‘git push origin main’ (‘origin’ and ‘main’ may be substituted with other values if your main branch and project names are different). If the steps listed above are performed correctly, the terminal should show statistics of your project and inform you about the successful transfer of files.
Publish the Website
Finally, go to Settings of the project on GitHub and choose Pages. In the Source menu, choose the main branch and root of the project and press Save. The service will post the link to your website that can be added to the project description on its home page. Mind that it can take up to several hours to publish the website. But the result will be worth the wait. Congratulations! You just hosted your first website!
Hosting a website on GitHub can look challenging as you see the service and all the requirements and entries for the first time. It’s a lot to process, indeed. We hope that this ultimate guide will help you avoid most of the potential issues and publish your website without hassle!