只用md添加分类及发布文章
1. 创建分类
- 在 _config.yml 文件的category 下添加
demo: 类别显示名
然后在 categories:下添加- name: demo title: 类别显示名
- 然后在category下创建文件夹
demo
,demo
文件夹下创建文件 index.html:复制default文件夹下的 index.html 文件过来, 修改如下两项的值
demo
和类别显示名
替换为新创建的名称title: 类别显示名 category assign list = site.categories.demo
2. 发布文章
-
在 _post 文件夹下创建要发布的文章文件, 文件名格式(-连接):
四位年份-两位月份-两位日期-文章标题.md
为了文件分类,_post下可以随意创建文件夹/_post/2018/12/ 只要文件名符合要求即可 -
文章内容开头如下:
--- layout: post title: 文章标题 category: demo --- 以下是文件正文, `注意`: demo 是该文章的分类, 见上一步创建分类中demo
3. 字数统计与阅读时长
- 字数统计
> 中文字数统计 { { content | strip_html | strip_newlines | split: "" | size } } > 英文字数统计 { { page.content | number_of_words } } > 阅读速度 成人350~500字/分 { % assign en = page.content | number_of_words % } { % assign zh = content | strip_html | strip_newlines | split: "" | size % } { % assign ch = en | plus: zh % } { % assign read = ch | divided_by: 500 % } 约 { { ch } } 字,阅读需 { { read } } 分钟
4. 评论和统计
5.新窗口打开链接
js代码批量添加
let arr =document.getElementsByTagName("a"); arr = [].slice.call(arr); arr.forEach(el => { if(el.getAttribute("href") && el.getAttribute("href").startsWith("http")){ el.setAttribute("target", "_blank") } })
在需要链接的位置, 用 html
<a href="https://sijiu.github.io" target="_blank">跳到自己博客列表</a>
参考:
统计等功能
为Jekyll博客添加小功能
Jekyll实现文章阅读耗时与字数统计
jekyll生成博客后markdown页面超链接添加target=’_blank’通过新窗口打开