运行jekyll生成的文件没有jekyll /本地服务器? [英] Running jekyll generated files without jekyll / local server?

查看:176
本文介绍了运行jekyll生成的文件没有jekyll /本地服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始与杰基尔合作。作为前端开发人员,我必须在开发之前为Web应用程序创建大量静态页面。



我试图在 _site 没有服务器的文件夹作为我的工作流的一部分,我必须将纯静态HTML文件发送给其他开发团队或在演示期间向客户端展示(有时作为zip文件夹,因此无法在配置文件中硬编码任何特定路径)



我无法从本地文件夹(如 file:/// C:/ Users / 因为所有的链接和资产只有在从jekyll服务器运行时才能工作。



有没有什么办法可以实现这一点。



感谢

解决方案

这对Jekyll来说根本不可能,因为索引页是不同的层次结构(/ index ),每篇博文都是一个嵌套的URL(/ posts / about)。因此,对于每个页面,CSS和Javascript之类的网址都必须有所不同。对于帖子应该是../ css / ...,对于索引应该是./css/。如果没有正在运行的服务器,这是不可能的。



所以这里有一些选项适合您:


  • 传递。作为基础网址。所以你的风格将变成'./css/'。现在你的索引页可以正常工作,但博客文章不会(他们需要'../')

      jekyll serve  -  - 基本。 


  • 传递当前文件夹作为基本URL。现在您不需要服务器,但是您的_site文件夹与您的机器文件夹绑定在一起,而不是完全可移动的。

      jekyll serve --baseurl $(pwd)


  • 使用轻量级服务器。这将在当前文件夹上启动一个简单的服务器(所以确保你进入_site文件夹),所以你不需要安装jekyll。这在Python中默认是可用的,所以只要安装了python,你就不需要单独安装任何东西。

      python -m SimpleHTTPServer< port> 



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

解决方案

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>
    

这篇关于运行jekyll生成的文件没有jekyll /本地服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆