Using Live Reload with Jekyll

I start with the Jekyll static site generator and I would like to use Live Reload . I know that Jekyll has generator and server commands, and Live Reload can run various compilers and custom commands. How to configure them for collaboration?

+45
ruby jekyll
Dec 06 2018-11-11T00:
source share
9 answers

The simplest approach I found is to use two terminal windows: one for jekyll serve --watch and one for guard .

I tried the guard-jekyll-plus approach proposed by Nobu , but I had a lot of errors.

As Shumushin pointed out , Jekyll can handle the automatic rebuilding process, you just start it with jekyll serve --watch

Now, to start the LiveReload operating mode with the guard-livereload function in the second terminal window. This is basically the same as Jan Segre's answer , but without guard-jekyll .

My Guardfile as follows:

 guard 'livereload' do watch(/^_site/) end 

And my Gemfile :

 gem 'jekyll' gem 'guard' gem 'guard-livereload' 

Note You still need to enable the script download function on the index.html page; this is the β€œglue” that ties guard-livereload and the browser together.

 <script src="http://localhost:35729/livereload.js"></script> 
+17
Apr 02 '15 at
source share

For jekyll 1.0+ use:

 jekyll serve --watch 

See Jekyll: Main Use for more details.

+32
May 16 '13 at 21:33
source share

Here's guard-livereload , which you can use with guard-jekyll and centralize the process of viewing guard , an example could be (I haven't tested it):

  • Install a protective sheath, either through a gem or using a bundle
  • Install a protective shroud, either through the pearl or in the scope of delivery

Init guard-jekyll

 guard init jekyll 

Add this to your Guard file:

 guard 'livereload' do watch(%r{_site/.+}) end 

You can adapt the above to better suit your project, and you probably already know that you need to include a script on your page:

 <script src="http://localhost:35729/livereload.js"></script> 

Oh, and start the whole looking mess:

 guard 
+23
04 Oct '13 at 4:23
source share

UPDATE: this no longer works with the latest version of Jekyll

 cd your/site/folder jekyll --server --auto 
+15
Dec 25 '11 at 4:50
source share

This post explains a cleaner way - Setting up LiveReload with Jekyll

Gemfile:

 gem 'jekyll' gem 'guard' gem 'guard-jekyll-plus' gem 'guard-livereload' 

Guardfile:

 guard 'jekyll-plus', :serve => true do watch /.*/ ignore /^_site/ end guard 'livereload' do watch /.*/ end 

Install any LiveReload browser extension . Then run guard .

+13
Mar 26 '14 at 1:01
source share

I wrote a Jekyll plugin called Hawkins that includes LiveReload in the Jekyll watch process. It works with Jekyll 3.1 and higher.

Just add

 group :jekyll_plugins do gem 'hawkins' end 

into your Gemfile (and then a bundle install ). From there you can run jekyll liveserve . Hawkins will change the head sections of your pages to include the necessary components for LiveReload, and when Jekyll detects a page change, Hawkins will push the message to your browser via WebSockets. Please note that you will need a browser that supports WebSockets . For a very fast reload, you can use the new function --incremental Jekyll, which will only restore modified pages.

+10
Mar 28 '16 at 15:11
source share

Start by launching jekyll, usually in your site’s folder:

 cd your/site/folder jekyll 

By default, Jekyll creates a folder inside it called _site ( your/site/folder/_site ).

Tell LiveReload to see what the _site folder is.

+4
Dec 09 '11 at 8:19
source share

I just started using GitHub Pages today and wanted to be able to use live reboot with Jekyll. Got his job and wrote his first post on Creating GitHub Pages with Jekyll and LiveReload .

It uses Grunt with the grunt-contrib-watch plugin instead of the Jekyll serve command - works well for me. Hope this works for you too.

+1
Jan 25 '14 at
source share

You can only use jekyll serve -w , which option I prefer as I am lazy.

0
May 13 '14 at 9:06
source share



All Articles