使用jekyll主题

时间:2023-03-09 08:15:57
使用jekyll主题

github上面有很多基于jekyll的主题

https://github.com/theme4jekyll

使用起来也非常方便。直接clone到本地

这些主题,包括了很多模板,在新建博客的时候可以在开头需要写一些标签,如果为了方便的话,提前写好一个程序来完成将会变得非常方便。

比如我写了一个。这个就在主题文件夹下面(newPost.rb)

 time = Time.new
timestr = time.strftime("%Y-%m-%d-")
puts "title: "
title = gets.chomp!
puts "dir: "
dir = gets.chomp!
puts "tags: "
tags = gets.chomp!
str = <<here
---
layout: post
title: #{title}
modified:
categories: #{dir}
description:
tags: [#{tags}]
image:
feature: abstract-5.jpg
credit:
creditlink:
comments: false
share: false
---
here dir = File.join("_posts",dir)
puts dir
Dir.mkdir(dir) unless File.exist?(dir)
filename = File.join(dir,timestr + title + ".md")
File.open(filename,"w+"){|file|
file.puts str
}

这样每次要新建一篇文章的时候就可以使用ruby newPost.rb,然后输入title,dir,tags等就会在相应的位置生成一个带头的文本了。

当然使用其它的任何语言都可以。而且如果你的文本编辑器可以保存头,那么就更方便了。