I’m starting to use make to steer my jekyll work, and find it saves much typing. One specific target is make serve. There after bundle exec jekyll serve --livereload I want to start the browser on port 4000 when the building is done. So far I do the following:
This allows jekyll to build and enter serve mode, while in the background the browser is started after 5 s. This is not fully satisfactory since the 5 seconds are frequently not enough.
Better ideas?
PS: For those (like me!) to very fluent in shell speak: the parentheses form a “command group”, allowing the 2-command sequence to be converted to a background job via the ampersand symbol.
Ah, you’re right, the option isn’t documented on the site. It does appear in the command-line help (jekyll help serve). I’ve sent in a pull-request to fix the site.
The --open-url option doesn’t take an argument, so the http://localhost:4000/ is unnecessary. To set the host and port, there are --host/--port options. For example, to serve the site on the local net from the computer named “Eddy” on port 8080:
Thank you again! I was not aware that jekyll -h could be augmented with a subcommand! Now I see the many options, also for the other subcommands. And I’ve left off the URL.
Interesting: while --livereload can be placed into _config.yml as livereload: true, this does not seem to be the case for --open-url.
I like to use Firefox Developer edition when I’m building stuff but the regular edition when I’m just surfing. I’ve installed the npm package parallelshell globally and have an alias defined with parallelshell "bundle exec jekyll serve --livereload" "~/.local/share/firefox_dev/firefox 'http://localhost:4000/'"
The only thing to know with this is when you kill the server with Ctrl+C, it closes the browser.
thank you for posting this. Works great. I now use alias jekyllserver="jekyll serve --host 0.0.0.0 --open-url"
and this leaves the tab open in safari when I stop the jekyll serve command. reload is done by watch.rb script.