CSDN—>Jekyll搭建个人博客

先缅怀一下CSDN,从15年开始使用CSDN写技术博客到现在,一年半啦,时间真的过的很快……缅怀结束。

第一篇记录一下使用Jekyll搭建这个博客的过程。

安装Jekyll

官网地址:https://jekyllrb.com/

  1. 安装,默认主题是minima

    1
    2
    3
    4
    5
    ~ $ gem install jekyll bundler
    ~ $ jekyll new my-awesome-site
    ~ $ cd my-awesome-site
    ~/my-awesome-site $ bundle exec jekyll serve
    # => Now browse to http://localhost:4000
  2. 由于需要做定制(比如需要去除RSS功能,调整页面效果),通过一下命令获取到指定theme的代码,将代码复制到站点目录下

1
$ open $(bundle show minima)

jekyll目录结构

http://jekyllrb.com/docs/structure/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
.
├── _config.yml // 配置主页的Title,邮箱,描述,站点主题等
├── _data
| └── members.yml
├── _drafts
| ├── begin-with-the-crazy-ideas.md
| └── on-simplicity-in-technology.md
├── _includes // _layout目录下的文件通过liquid可以获取该目录下的部分
| ├── footer.html
| └── header.html
├── _layouts // post.html代表文章页面的布局
| ├── default.html
| └── post.html
├── _posts // 文章按"年-月-日-标题"的格式命名
| ├── 2007-10-29-why-every-programmer-should-play-nethack.md
| └── 2009-04-26-barcamp-boston-4-roundup.md
├── _sass
| ├── _base.scss
| └── _layout.scss
├── _site
├── .jekyll-metadata
└── index.html # can also be an 'index.md' with valid YAML Frontmatter

自定义Jekyll主题

Gemfile添加要安装的主题,有点像Podfile文件添加需要pod的项目:

1
gem "jekyll-bootflat"

_config.yml设置主题:

1
theme: jekyll-bootflat

终端执行:

1
2
3
$ bundle
// Or install it yourself as
$ gem install jekyll-bootflat

添加评论系统

创建评论账号

  1. https://disqus.com 注册账号,
  2. register your site 输入网站,类型,语言创建该站点的评论账号
  3. install Disqus on your site using the shortname registered.
  4. 从该网站的配置中获取到shortname为https-jolieyang-github-io

Jekyll配置

  1. 设置page.comments为True,在post.html中头处添加:

    1
    2
    3
    4
    ---
    layout: default
    comments: true
    ---
  2. 设置site.disqus.shortname,在_config.yml添加:

    1
    2
    disqus:
    shortname: shortname

参考资料

Creating and Hosting a Personal Site on GitHub