Home > Development Tools > git > body text

How to set up a github blog on mac

PHPz
Release: 2023-04-06 14:32:14
Original
693 people have browsed it

Nowadays, more and more people are choosing to set up their own blogs on the Internet. This method not only provides enough freedom, but also allows them to demonstrate their technical abilities. For Mac system users, how to set up your own GitHub blog is also a good practice.

GitHub is the world's largest code hosting website, which provides a variety of features, including blog hosting. Moreover, GitHub Pages fully supports Jekyll - an excellent static website generator that not only can generate websites quickly, but is also simple and convenient to use.

So, next, let’s learn more about the specific steps to build a GitHub blog on Mac system:

Step one: Register a GitHub account and create a code repository

In GitHub After registering an account and logging in, create a new code repository with the naming format "username.github.io", where "username" is the name of your GitHub account. This code repository is the root directory of your GitHub blog website, and all content will be saved here.

Step 2: Install Jekyll

Jekyll is a program written in Ruby language. You need to first ensure that Ruby has been installed on the Mac system, and then install Jekyll through the following command:

$ gem install jekyll bundler
Copy after login

After the installation is complete, use the following command to generate a new Jekyll website locally:

$ jekyll new myblog
Copy after login

"myblog" here is the directory name of your blog website, you can modify it yourself.

Step 3: Set up Jekyll

Open the "myblog" directory you just created, find the _config.yml file, and modify some configuration items in it, as shown below:

url: "https://username.github.io"
baseurl: "" # 将这里的“/”改为空格
Copy after login

The "username" represents your account name on GitHub.

Step 4: Use Jekyll to generate the website

Use the following command to generate the website in the local development environment:

$ bundle exec jekyll serve
Copy after login

This command will automatically generate a static website and start it locally A web server that can access the local blog website through http://localhost:4000.

Step 5: Push the website to GitHub

After completing editing the website content locally, you can push the website to GitHub through the following command:

$ git add --all
$ git commit -m "Initial commit"
$ git push -u origin master
Copy after login

"master" here "The branch is fixed and cannot be modified.

In your GitHub account, enter the code repository you just created, click "Settings" -> "GitHub Pages", select Branch as "master", and save the settings. After saving successfully, you can access your blog website at "https://username.github.io".

Summary:

Through the above steps, we can build our own GitHub blog website on the Mac system, and it is completely free. Although it requires some basic technical reserves, I believe that as long as you read the steps carefully and follow the operations, you can build it successfully. Let’s encourage each other.

The above is the detailed content of How to set up a github blog on mac. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!