How to use Jekyll+GitHub Pages to build a personal blog site

As a sentimental engineer, I usually use blogs to record my life, growth, work experience or experience. Most people use blogs to go through the following stages:

(1) Recorded in the brain (not recommended)

(2) Use XXX cloud notes

(3) Use iteye, csdn, 51cto, Open Source China, Blog Park, Jianshu, etc.

(4) Use personal website + WeChat public account

(1) What is Jekyll

jekyll is a static blog generator, which can be used to convert the articles we wrote using markdown into static web html for publishing.

(2) What is Github Pages

Github Pages is a public static page building hosting service open to users, organizations and projects. Sites can be hosted on Github for free. You can choose to use the default domain name github.io provided by Github Pages or a custom domain name to publish the site. Github Pages supports automatic site generation with Jekyll, as well as plain HTML documents.

(3) How to build and use

Preconditions:

git环境
github账户
ruby环境 

The bottom layer of jekyll is written in ruby, so you need to install the ruby ​​environment first when installing:

You need to install some software on the mac first, assuming you already have the git environment:

brew install ruby

gem install jekyll

gem install bundler

gem install jekyll-paginate

gem install jekyll-gist

After the above software is installed, you can search for a project based on the jekyll template on github. Of course, you can search for any theme style you like from the Internet, and use git clone to your local after finding it:

git clone xxx.git  myblog

cd myblog

jekyll server

Then visit http://localhost:4040 to preview your blog locally

If you like this theme, then you can fork yourself to github, then clone it, modify some places, and then push yourself to the repository, that's it, some git operation commands:

git add .
git commit -m "first commit"
git remote add origin https://github.com/alex-my/alex-my.github.io.git
git push -u origin master

For the directory structure of jekyll's blog, if you are interested, you can refer to the official website documentation: http://jekyllcn.com/docs/structure/

The articles we write are generally in the _posts directory, and its format is as follows:

2018-04-11-spark sql大数据量下的调优和实践.md

The front is the date, the middle is the title, and the suffix is ​​generally md, which looks relatively concise.

(4) Bind yourself to a domain name

Finally, let’s talk about the project in github. After entering the project root directory, click the Settings configuration option in the upper right corner, where you can configure your own site domain name. What I configure here is my own domain name. By default, it is generally username.github .io like mine is:

qindongliang.github.io

This looks a bit rudimentary, so it is very easy to bind the domain name we already have to github pages. First, suppose we already have a domain name. If we don't have one, we can buy it online, and then go to the static site by ourselves to the root directory. , create a new file with the name as CNAME, and the content inside is our own domain name, such as mine:

8090nixi.com

Note that you only need the part behind the domain name, you don't need to write both http and www, and then log in to the domain name management center, here is the part of Alibaba Cloud's domain name resolution, add a CNAME record:

CNAME @  qindongliang.github.io

After the configuration is completed, it will generally take effect within 10 minutes. If there is no accident, you can access our static site through our custom domain name in a while.

So far, an independent personal site of our own has been completed. The advantages and disadvantages of using jekyll+github pages are as follows, borrowing the summary of Mr. Ruan Yifeng:

advantage:

   * 免费,无限流量。

  * 享受git的版本管理功能,不用担心文章遗失。

  * 你只要用自己喜欢的编辑器写文章就可以了,其他事情一概不用操心,都由github处理。

shortcoming:

  * 有一定技术门槛,你必须要懂一点git和网页开发。

  * 它生成的是静态网页,添加动态功能必须使用外部服务,比如评论功能就只能用disqus。

  * 它不适合大型网站,因为没有用到数据库,每运行一次都必须遍历全部的文本文件,网站越大,生成时间越长。

But for small and medium-sized sites, it is undoubtedly a good solution. Interested friends can try it out. I personally prefer a simple site style. You can feel it through the blog button in the menu bar at the bottom of my official account.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325473061&siteId=291194637