使用Github和Jekyll制作静态主页
Jekyll是Ruby的一个Gem。Ruby是一种编程语言,而Gem是Ruby库的意思。Ruby词义为红宝石,Gem词义为经切割、磨光后的宝石,二者的关系亦由词义暗示。
以Ubuntu系统为例说明主页的本地搭建。运行ruby -v
可查看安装的Ruby版本,间接判断是否已安装Ruby。在已安装Ruby的情况下,只需在终端中输入以下4行代码即可建立主页。
gem install jekyll bundler
jekyll new myblog
cd myblog
bundle exec jekyll serve
其中jekyll new myblog
一步可能用时较久,耐心等待即可。
新建主页默认使用的Jekyll主题是minima。查看主题文件使用命令bundle show minima
。
现在我们对minima主题作一些修改。
增加访问统计功能
使用不蒜子。首先将busuanzi.js
添加到_includes/head.html
中:
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
再在需要显示的位置,插入站点计数
<span id="busuanzi_container_site_pv">
点击n篇文章计n次的访问量<span id="busuanzi_value_site_pv"></span>次
</span>
<span id="busuanzi_container_site_uv">
点击n篇文章计1次的访客数<span id="busuanzi_value_site_uv"></span>人次
</span>
和单页计数
<span id="busuanzi_container_page_pv">
浏览数<span id="busuanzi_value_page_pv"></span>次
</span>
增加评论功能
使用Utterances。Utterances基于Github Issues,不依赖第三方网站。首先在自己网页的Github仓库下安装utterances app,随后,在需要放置评论处插入
<script src="https://utteranc.es/client.js"
repo="[ENTER REPO HERE]"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
评论者需通过Github OAuth授权给Utterances来代替他们发布Github Issues。
Statement: 1. The copyrights of all original posts in this blog are reserved. For reposting, you do not need to contact the author. However, you need to indicate Siberian Tiger as the author and attach the links of the posts. 2. All reposted posts are marked as "reprint" with authors indicated and links provided. Should there be copyright infringement, please contact the author as per the "About" page. The author will delete the content as soon as possible.