Home > Article > Development Tools > How to use GitHub Pages to build a personal website and blog
GitHub Pages is a free static website hosting service provided by github. It can host Markdown, HTML, CSS, JavaScript or other static files into your GitHub Pages account. It supports a variety of custom domain names and themes, is compatible with Jekyll, and can also customize 404 pages, etc. It is very flexible and powerful. Therefore, it is more popular to use GitHub Pages to build personal websites and blogs.
1. Register a Github account
First of all, you need to have a github account. You can register through the Github official website https://github.com/. The registration process will not be described in detail.
2. Create a repository
Create a new GitHub repository with "username.github.io" as the repository name. At this time, the warehouse name must be username.github.io, where username is your GitHub username.
If you want to use a custom domain name, do not use this method to create a warehouse. You can create an additional warehouse with a custom domain name.
3. Upload website files
Use the git tool to clone, then create and upload your static website in the local warehouse.
Create a new file named "index.html" in the local directory, and write the HTML code of your personal website in the file.
You can enter the following command to initialize the warehouse:
$ cd /path/to/local/repo $ git init $ git add . $ git commit -m "first commit"
Next, push the warehouse directly to GitHub.
$ git remote add origin https://github.com/username/username.github.io.git $ git push -u origin master
After the upload is completed, you can view your personal website at https://username.github.io/. This URL is also the publishing address for all your personal websites in the future. When you update your website Then, visitors will see the latest content on the website.
If you want to use a custom domain name, you need to fill in your registered domain name in GitHub's "Settings" -> "Custom domain", and then set up domain name resolution in DNS.
4. Use Jekyll theme
Jekyll is the default static website generator for GitHub Pages. It is free, open source and compatible with most themes.
First you need to install the Ruby language on the local computer, and then enter the following instructions in the command line:
$ gem install jekyll bundler
Next, clone a Jekyll theme to the local computer, then replace the file contents and replace it Upload to the GitHub Pages repository.
$ git clone https://github.com/the-name-of-the-Jekyll-theme.git $ cd the-name-of-the-Jekyll-theme $ bundle install $ jekyll serve
At this point, you can view your personal website in the browser of your local computer, and then push the theme directly to GitHub, and the theme will be used on your website.
5. Summary
Building personal websites and blogs through GitHub Pages allows us to better express ourselves, and also provides us with a platform for learning and communication, which is very important for personal development and work. All of great help. This is just a brief introduction. More functions and usages need to be explored and learned by yourself.
The above is the detailed content of How to use GitHub Pages to build a personal website and blog. For more information, please follow other related articles on the PHP Chinese website!