Running jekyll generated files without jekyll / local server?

前端 未结 3 673
無奈伤痛
無奈伤痛 2021-01-04 20:42

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 t

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-04 21:22

    Edit: I've just posted a new answer using relatives links. Which is more portable solution.

    I see three solutions to your problem :

    Distribute your code via Github Pages

    Use a public or a private repository on Github Pages to serve you work. You can use the ideas developed by Octopress to store your code and the generated files on two different branches of your repository and give access to your plain html to developers.

    Configure Jekyll to (nearly) work on file system

    By using the baseurl configuration variable in _config.yml.

    If the site's zip is unzipped in C:/Users/toto/mysite, add :

    # No trailing slash
    baseurl: "file:///C:/Users/toto/mysite"
    

    In default Jekyll templates, assets are called with :

    
    or
    
    

    Links and images must make use of baseurl to :

    # html link
    {{ page.title }}
    
    # markdown link
    [{{ page.title }}]({{ site.baseurl }}{{ page.url }})
    
    # html image
    
    
    # markdown image
    ![Img title]({{ site.baseurl }}/assets/myimage.png)
    

    Note : Any page that has a permalink set to end with folder/index.html (eg: permalink: /about/) will result in having link targeting folder/ and land on the folder's files listing page.

    Give a try to an exotic solution for Win users

    You can give a try to Portable Jekyll that seems to work on windows.

提交回复
热议问题