Use Jekyll without Jekyll server / without root directory

I just started using Jekyll today, and I'm trying to figure out how to use it to create a portable static site. In particular, I want to have access to the site without using the Jekyll server.

This answer says that this is impossible, however, it’s a couple of years, and it seems that the static site generator should be able to generate a site that the server does not need to work (it can be accessed through a browser as a file file:///...)

Jekyll docs say that a Jekyll site can be deployed to a remote server by placing the _site / folder in the web server’s root directory. How can I force Jekyll to use relative links so that I can start the site from a directory other than the root?

I am worried that the answer to this question is “impossible” or at least “it is impossible without any deceit”. I have used Wordpress in the past, and it is trivial to configure the installation of wordpress in any directory on the LAMP server. I feel there must be some easy way to do this with Jekyll, but I can't find the answer anywhere.

+1
source share
1 answer

This answer remains valid. But I have to admit that it is not very portable to configure baseurl. You cannot always guess the right path.

Try making it run on a file system with related URLs, for example ./path/to.

What do we need to configure

, file:///path/to/_site/index.html, :

  • .
  • file:///jekyll/update/2016/08/05/welcome-to-jekyll.html /:categories/:year/:month/:day/:title.html permalink. , hierachy - .
  • . , , /about/, , file:///about/

, .

_config.yml :

defaults:
  -
    scope:
      type: "posts"
    values:
      permalink: :slug:output_ext

  -
    scope:
      type: "pages"
    values:
      permalink: :basename:output_ext

.

about. ?

permalink . permalink: /about/ front.md, /path/to/_site/about.html. !

, ./.

_includes/head.html

<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">

<link rel="stylesheet" href="{{ "./main.css" }}">

_includes/header.html

<a class="site-title" href="{{ site.baseurl }}/">{{ site.title }}</a>

<a class="site-title" href="./index.html">{{ site.title }}</a>

<a class="page-link" href="{{ my_page.url | prepend: site.baseurl }}">{{ my_page.title }}</a>

<a class="page-link" href="./{{ my_page.url }}">{{ my_page.title }}</a>

index.html

<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>

<a class="post-link" href="./{{ post.url }}">{{ post.title }}</a>

.

, .

+3

All Articles