我从Jekyll static site generator开始,我想用Live Reload.我知道Jekyll有一个生成器和服务器命令,Live Reload可以运行各种编译器和自定义命令.我该如何配置它们以使其协同工作?
我从Jekyll static site generator开始,我想用Live Reload.我知道Jekyll有一个生成器和服务器命令,Live Reload可以运行各种编译器和自定义命令.我该如何配置它们以使其协同工作?
UPDATE:正如其他答案所指出的,LiveReload内置于Jekyll 3.7+中.
jekyll serve --livereload
我发现最简单的方法是使用两个终端窗口:一个用于jekyll serve --watch
,一个用于guard
.
我试了guard-jekyll-plus approach suggested by Nobu次,但我犯了很多错误.
作为shumushin pointed out,Jekyll可以处理自动重建过程,您只需使用jekyll serve --watch
启动它
现在要让LiveReload工作,请在第二个终端窗口中运行guard和guard LiveReload.这与Jan Segre's answer基本相同,但没有guard-jekyll
.
我的Guardfile
是这样的:
guard 'livereload' do
watch(/^_site/)
end
还有我的Gemfile
:
gem 'jekyll'
gem 'guard'
gem 'guard-livereload'
Note:你仍然需要在你的index.html
页中包含livereload脚本;正是"gulp "将guard-livereload
和浏览器结合在一起.
<script src="http://localhost:35729/livereload.js"></script>