Jeklly搭建博客

开通自己的github.io repo
步骤当然,一切的前提是你得首先有个github的账户,这里还请自行解决。登陆你的账户后,你可以创建一个新的repo。请务必注意该repo的名字,必须保持格式.github.io,其中替换成你的github账户名,这里假定创建的repo为sevenrad.github.io
github.io
把你创建的repo clone到本地
当我用HTTPS时:

git clone https://github.com/sevenrad/sevenrad.github.io.git
Initialized empty Git repository in /root/zhouyunlai/fqQuality/MicroFun/STAMP/STAMP/stamp/sevenrad.github.io/.git/
error:  while accessing https://github.com/sevenrad/sevenrad.github.io.git/info/refs

fatal: HTTP request failed

于是:

git clone git@github.com:sevenrad/sevenrad.github.io.git
Initialized empty Git repository in /home/GitHub/sevenrad.github.io/.git/

成功了。然后:

$ cd sevenrad.github.io
$ echo "Hello World" > index.html
$ git add index.html
$ git commit -m "Init commit"
$ git push origin master

打开博客网站https://sevenrad.github.io//出现了 Hello World。

选择一款Jekyll的主题
Fork出自己的repo

为了便于管理,建议先把Huxpro fork到自己的账户下

clone样板repo

git clone git@github.com:Huxpro/huxblog-boilerplate.git
Initialized empty Git repository in /home/zhouyunlai/GitHub/sevenrad.github.io/huxblog-boilerplate/.git/
remote: Counting objects: 1833, done.
remote: Total 1833 (delta 0), reused 0 (delta 0), pack-reused 1833
Receiving objects: 100% (1833/1833), 31.24 MiB | 166 KiB/s, done.
Resolving deltas: 100% (1191/1191), done.

OR clone主题

$ git clone git@github.com:keysaim/huxpro.github.io.git
添加自己的github.io git repo
clone了huxpro的repo之后,需要将自己创建的github.io repo设置到clone的repo:

cdhuxpro.github.io c d h u x p r o . g i t h u b . i o git remote add mine git@github.com:sevenrad/sevenrad.github.io.git
修改必要的配置

clone之后的repo其实是Huxpro自己的博客网站,里面有非常多作者自己的博文,可根据自己的需要进行必要的删减。基于Jekyll的博客网站,对于配置,非常重要的一个文件是_config.yml文件,代开这个文件进行必要的修改:

title: 小蛋是猪的Blog
SEOTitle: Ryan的博客 | 小蛋是猪 Blog
header-img: img/home-bg.jpg
email: bingcanzhou@gmail.com
description: "关于前端与设计,Web & Mobile Lover,Software Engineer,UX Designer | 这里是 @ZBC 的个人博客,与你一起发现更大的世界。"
keyword: " 博客, 个人网站, 互联网, Web, JavaScript"
url: ""              # your host, for absolute URL
baseurl: ""                             # for example, '/blog' if your blog hosted on 'host/blog'

编写发布博客
Jekyll对于博文,都是要求放在_posts目录下面,同时对博文的文件名有严格的规定,必须保持格式YEAR-MONTH-DAY-title.MARKUP,通常情况下,咱们采用推荐的Markdown撰写博文,基于该格式,本博文的文件名为_posts/Books/2018-03-04-book-test.markdown

写好博文之后,就可以通过git提交博文了:

$ git add _posts/Books/2018-03-04-book-test.markdown
$ git commit -m "Add how to setup your github.io blog"
$ git push mine master

我push的时候出了一次错,然后看了这个就解决了由于github仓库中提前建立readme文件,导致git push报错error: failed to push some refs to ‘git@github.com:

其中,mine就是前面设置的你自己的repo。等一会(通常几秒到几十秒不等),就可以打开自己的博客网站查看博文了,这里是我的博客网站https://sevenrad.github.io/

所有n元素都是套用模板,大致是这样的:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值