Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jekyll serve and launch

Tags:

bash

jekyll

Being lazy, I would like to chain the following two commands so that it will work with one simple bash alias.

jekyll -w serve

starts up the development server for my jekyll instance.

open "http://localhost:4000"

launches my jekyll application in my default browser.

How can I chain them together so that I can type one simple alias in my command line to serve and launch?

NOTES

  • Note using either && or ; to chain jekyll -w serve and open "http://localhost:4000" will not work because the jekyll -w serve launches the persistent webrick process in stdout. Which means that the 2nd command open "http://localhost:4000" will not be executed because the first process (webrick) never did "complete".

  • When webrick starts, we can see a typical output as follows:-

Configuration file: /Users/calvin/work/calviny/_config.yml
            Source: /Users/calvin/work/calviny
       Destination: /Users/calvin/work/calviny/_site
      Generating... done.
 Auto-regeneration: enabled
[2013-09-08 18:43:58] INFO  WEBrick 1.3.1
[2013-09-08 18:43:58] INFO  ruby 1.9.3 (2013-06-27) [x86_64-darwin11.4.2]
[2013-09-08 18:43:58] INFO  WEBrick::HTTPServer#start: pid=6183 port=4000
like image 660
Calvin Cheng Avatar asked Sep 08 '13 10:09

Calvin Cheng


People also ask

What is jekyll used for?

Jekyll is a free and open source static site generator. Like a content management system (for example, Drupal and WordPress), Jekyll can be used to build websites with rich and easy-to-use navigation.

What is GEM jekyll?

A Gemfile is a list of gems used by your site. Every Jekyll site has a Gemfile in the main folder. For a simple Jekyll site it might look something like this: source "https://rubygems.org" gem "jekyll" group :jekyll_plugins do gem "jekyll-feed" gem "jekyll-seo-tag" end.

How do I change the port on my jekyll?

To change port number, you can edit docker_run.sh file. If you want to update jekyll, install new ruby packages, etc., all you have to do is build the image again using docker_build_image.sh ! It will download ruby and jekyll and install all ruby packages again from scratch.


1 Answers

As of v3.70 these hacks are no longer needed. Now jekyll serve has LiveReload functionality and will automatically spawn the default browser with the -o, --open-url option. The -l, --livereload option will automatically rebuild and refresh the browser upon changes.

bundle exec jekyll serve -l -o
like image 159
Spencer Mathews Avatar answered Oct 16 '22 21:10

Spencer Mathews