I have just started working with Jekyll. As a front-end developer i have to create a lot of static pages for web applications before they go into development.
I am trying to run jekyll generated files inside the _site
folder without a server as sometime as part of my workflow i have to send plain static HTML files to other dev team or show to clients during a presentation (sometimes as a zip folder so can't hardcode any specific path in config file).
I am not able to run jekyll files from a local folder like file:///C:/Users/
as all the links and assets only work while running from a jekyll server.
Is there any way that this can be achieved.
Thanks
Using Jekyll To view the website locally, go to http://localhost:4000. Afterwards you can press ctrl-c to stop the process in the terminal. You can also add the --watch command at the end to force Jekyll to rebuild the site every time you save the file.
GitHub Pages has been the go-to web host for Jekyll sites as it is totally free, and easy to integrate with your existing code repository.
Jekyll is software that creates websites. Jekyll isn't actually “running” the live website; rather, Jekyll is a “static site generator”: it helps you create the static site files, which you then host just as you would any other HTML website.
This is fundamentally impossible with Jekyll, because the index page is a different hierarchy (/index) and each blog post is a nested URL (/posts/about). So the URLs for things like CSS and Javascript will have to be different for each page. For a post it should be "../css/..." and for index it should be "./css/". That is not possible without a running server.
So here are some options for you:
Pass "." as the base url. So your styles will become './css/'. Now your index page will work fine, but blog posts won't (they need '../')
jekyll serve --baseurl .
Pass the current folder as base URL. Now you don't need a server, but your _site folder is tied to your machine's folder, and not exactly portable.
jekyll serve --baseurl $(pwd)
Use a lightweight server. This will start a simple server on the current folder (so make sure you go into _site folder), so you don't need jekyll to be installed. This is available by default in python, so you don't have to install anything separate, as long as python is installed.
python -m SimpleHTTPServer <port>
You can view a built Jekyll site without a server - but it needs an extra tool.
Serve your Jekyll site as normal, and use wget to clone your served site in flat format. This will work on a linux system:
You may need to play about with wget settings, but if your site is served on port 4000 you could try something like this:
wget --convert-links -r http://127.0.0.1:4000/
You'll probably need to be careful with the recursive flag. See http://www.gnu.org/software/wget/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With