Jekyll serve (locally) without construction

Jekyll creates a static site in this directory (by default, _site ). Running jekyll serve creates the site and then configures the server so that the site can be viewed locally on the specified port (for example, localhost:4000 by default). I am wondering if there is a way to activate this serve behavior without starting a gem in order to recompile the site first.

Alternatively, it would be sufficient to use some other tool to serve the site from the local port without using jekyll, but I'm not sure how to do it (node.js?). Although I can open static files directly in the browser, it does not find the correct links to relative URLs (before css, etc.). Instead, instead of linking /css/default.css to the root file://css/default.css , which, of course, does not happen.

(This would be useful, for example, because Jekyll takes quite a while to build a large site, and some plugins that I use require Internet access to various APIs. It would be nice to browse the site offline without them launch).

+6
source share
3 answers
 jekyll serve --skip-initial-build 

This will serve the site, skipping the initial build process. Additional configuration options for creating and maintaining the site can be found here .

+6
source

If you just want to service the already built _site directory, there are many ways to quickly start the web server locally. With ruby, you can just cd in _site and use WEBrick as follows:

 ruby -rwebrick -e 'WEBrick::HTTPServer.new(:Port=>4000,:DocumentRoot=>".").start' 

or python SimpleHTTPServer:

 python -mSimpleHTTPServer 4000 

Both set the port to 4000, but it can be any number.

+6
source

You can completely combine the building if you use another blogging platform, such as BlogDown. BlogDown is a static site generator that does not need to be compiled at all. You just replace the markup files, and you're good to go. https://github.com/thingdown/blogdown

0
source

Source: https://habr.com/ru/post/951069/


All Articles