How to create github blog

193 阅读1分钟

原文日期:2018-04-19


Remark

Because of the blog of github io is simple and easy, so I am planning use the github io to replace my blog site. Now write the article to record the step of crete github blog, For more infomation, as below.

Steps

A. Create a simple github blog

  1. Create a repository on github Create a new repository on github,and the repository's name have a fixed rule. For example, yourgithubname.github.io. this step is simple.

  2. To add the index page Create a index.html file on the repository ,and add hello world to the file. Now when you input https://yourgithubname.github.io in the browser, it show hello world. In the end, congratulation to you.

  3. Replace your blog theme

  • Find your repository and click on the Settings tab.
  • Scroll down to the Github Pages section, click on the Choose a theme button.
  • Pick a theme by you like, and click finish button.

tip:For more information, see: github pages site

B. Use jekyll on the blog,and local develoment

  1. Config Ruby environment and install jekyll.
  1. Create a blog by jekyll execute follow command.
$ jekyll new blog 

Now, you will found a blog directory in current directory. and the blog directory contains some files and a _posts directory, the _posts directory is used place the article.

About more information of jekyll directory and files: see jekyll directory.

  1. Copy the files to repository. copy the files of blog to the repository directory and push it to the github repository.

  2. Add article
    The new article must written the directory by named _posts. For more information about article, you can see: jekyll article.

  3. Start jekyll

$ jekyll serve  

tip:For more information: see jekyll site.
also see jekyll/liquid api document

C. Use your domain on the blog (Not Must)

  1. Add a domain resolve on your DNS provider.
  2. Add CNAME file to your repository, and write the domain on it.
  3. Add your custom to your Github Pages site.

Now, you can use your domain to access.

D. Use Paginate in your site

  1. At first, write it on the _config.yml file, as below
paginate: 5  
plugins:   
  - jekyll-paginate
  1. add jekyll-paginate plugin on the Gemfile, as below

gem "jekyll-paginate"

  1. If needed, update name of the index.md file to index.html. and it is a requirement of jekyll.

  2. install jekyll-paginate plugin

gem install jekyll-paginate

  1. Update the content of index.html file(show the pagination article). For example,as below
    page-article  
  2. add the pagination link infomation to index.html file. For example,as below
    page-link

Now, to visit your site, you will look the pagination effect.