无法让 site.baseurl 在 jekyll 中工作 [英] Can't get site.baseurl to work in jekyll

查看:45
本文介绍了无法让 site.baseurl 在 jekyll 中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Jekyll 创建一个 GitHub 项目页面.

I'm creating a GitHub project page with Jekyll.

我已阅读有关此主题的先前问题,以及 此处的 Jekyll 文档.

I've read the previous questions on this subject, as well as the Jekyll documentation here.

我已经尝试将 _config.yml 中的 baseurl 设置为 /my-projecthttp://myaccount.github.io/my-project 同时链接我的 CSS 和 js 文件,如下所示:

I've tried setting baseurl in _config.yml to both /my-project and http://myaccount.github.io/my-project while linking my CSS and js files like so:

<script src="{{ site.baseurl }}/js/javascript.js"></script>
<link href="{{ site.baseurl }}/css/style.css" rel="stylesheet">

当我运行 jekyll --serve --baseurl '' 时,在本地主机上一切正常.

When I run jekyll --serve --baseurl '' everything looks good on localhost.

但是当我推送到 github 时,我所有的 CSS 和 js 文件都是 404ing;链接正在变成 http://css/style.css 等等.

But when I push to github, all of my CSS and js files are 404ing; the links are getting turned into http://css/style.css and so on.

我在这里遗漏了什么?

我也对 _config.yml 中的 BASE_PATH 变量的用途感到困惑,而不是 baseurl.

I'm also confused about the purpose of the BASE_PATH variable in _config.yml, as opposed to baseurl.

我尝试设置 BASE_PATH 并以这种方式链接我的文件,但这也不起作用.

I tried setting BASE_PATH and linking my files that way, but that didn't work either.

推荐答案

我想通了 -- baseurl 没有被解析,因为我错误地将它放在了 JB 下: 散列在 _config.yml 中.我将 baseurl 移动到文件的不同部分,现在它可以正常工作了.

I figured it out -- baseurl wasn't getting parsed because I had mistakenly placed it under the JB: hash in _config.yml. I moved baseurl to a different part of the file and it's working properly now.

这篇关于无法让 site.baseurl 在 jekyll 中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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