Home > Article > Development Tools > How to set up a blog on Github
In the technical field, starting your own blog is a great way to showcase and share your skills. Among the many platforms for establishing blogs, Github blog is undoubtedly a very good choice. It is integrated on Github, which not only facilitates management, deployment, and maintenance, but also allows you to publish blogs for free through Github Pages. Here's how to set up a blog on Github.
Step 1: Create a repository
First log in to your Github account, enter the "Create a new repository" page, and then enter the name of the warehouse you want to create in the Repository name, such as "username. github.io", where username is the username you registered on Github, and then click "Create repository" to create a new repository.
Step 2: Create a blog
Next, create a folder named username.github.io locally, and future blog files will be stored in this folder. Create an index.html file in this folder. This file is the homepage of your website. You can add your personal information, blog posts, etc. to it.
Step 3: Use git to submit the code
Use git to push blog files to the remote warehouse. First, you need to add the remote warehouse address and use the following command:
git remote add origin git@github.com:username/username.github.io.git
where username is your username on Github, and then to push the code, use the following commands:
git add . git commit -m "Initial commit" git push origin master
These commands will push your code to the remote warehouse.
Step 4: Publish a blog on Github Pages
Publishing a blog on Github requires the use of the Github Pages function, which allows you to use the code in the Github repository to access it directly as a static website . To enable the Github Pages function, you need to enter the Settings page of the warehouse, then click "Choose a theme" to select a theme style, and then click "Select theme" to see your website.
Step 5: Publish the article
Your blog is now accessible, and you can publish the article next. In the local username.github.io folder, create a folder named _posts and add a markdown file in it. The file name format is YYYY-MM-DD-article-title.md, such as 2019-01-01 -hello-world.md, then add the article content in it, save it and submit it to the remote warehouse using git.
Summary
Now, you can publish your own blog on Github Pages. You can add personal information, blog posts, project information, etc. to show off your skills and share yourself with everyone. experience. Github Pages is free, realizes the construction and deployment of blogs, and can meet our needs well.
The above is the detailed content of How to set up a blog on Github. For more information, please follow other related articles on the PHP Chinese website!