标签插件(tag plugins)是hexo用于在文章中快速插入特定内容的插件。
hexo的很多插件类似octopress,有些插件的使用方法官方文档没有octopress的文档详细。
有些tag,markdown的语法就能实现类似的效果就使用更通用的markdown,按照我的使用先后来记录,慢慢补齐。
我使用的hexo版本是3.8.0
Include Code
插入代码,这个是可以把整个文件作为代码插入,这样做的好处是作为可运行的代码后续如果修正了bug,重新hexo g
一下文章中的代码就会自动更新;不需要每次从文件中拷贝粘贴代码到文章中。
配置code存放路径
在hexo的配置文件hexo/_config.yml
中看到code_dir: downloads/code
,说明所有的code文件都放到source/downloads/code
文件夹下。
语法
1 | {% include_code [title] [lang:language] path/to/file %} |
[title]
:可选,标题名,默认是文件名[lang:language]
:可选设置语言后,根据不同的语言设置语法高亮
举例
代码文件存放在source/downloads/code/hello_world.c
.
1 | {% include_code lang:c hello world in c lang hello_world.c %} |
1 |
|
frame
To embed an iframe:
1 | {% iframe url [width] [height] %} |
当然也可以直接插入HTML格式的标签。
1 | <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=247745&auto=0&height=66"></iframe> |
Reference: