【问题标题】:GitHub Pages build cannot find bootstrap sassGitHub Pages build 找不到 bootstrap sass
【发布时间】:2021-02-02 17:23:30
【问题描述】:

我有一个使用 Jekyll 的 GitHub 页面站点(一个项目页面),并且想在我的项目中使用 Bootstrap。 我下载了未编译的 twbs 文件,并在我的项目中的 _sass 目录下添加了 bootstrap、mixins 和实用程序文件夹。

我在我的主 sass 文件中导入 bootstrap,如下所示:

@import 'bootstrap/bootstrap';

当我运行 bundle exec jekyll serve 时,这在本地运行良好。

但是,当我将构建推送到 GitHub Pages 时,我收到以下错误:

Your SCSS file ci-dashboard/assets/css/style.scss has an error on line 2: File to import not found or unreadable: bootstrap/bootstrap. Load path: /hoosegow/.bundle/ruby/2.7.0/gems/jekyll-theme-primer-0.5.4/_sass.

我尝试了以下方法:

  1. 将此添加到我的 _config.yml 文件中
sass:
    sass_dir: _sass
    style: compressed
  1. 按照this post 中的说明,将baseurl 添加到我的config.yml 文件并尝试使用以下行在我的主css 文件中导入引导程序:
@import '{{ site.baseurl }}/bootstrap/bootstrap';

这个解决方案看起来很有希望,因为 jekyll 和 GitHub 页面使用相对链接似乎存在问题?我猜我的导入错误或在错误的地方?

  1. 按照this post 的建议,将我的.gitignore 文件中的vendor 替换为vendor/bundle

这是我的项目的结构:

├── _config.yml
├── _sass
│   ├── bootsrap
│   |   └──*lots of .scss files*
│   ├── mixins
│   |   └──*lots of .scss files*
│   └── utilities
│       └──*lots of .scss files*
├── assets
│   └── css
│       └──style.scss
├── _includes
│   ├── footer.html
│   └── header.html
├── _layouts
│   └── default.html
├── _site
└── Gemfile
etc. etc.

谢谢!

【问题讨论】:

标签: twitter-bootstrap bootstrap-4 sass jekyll github-pages


【解决方案1】:

我不知道您是否找到了答案,但我遇到了同样的问题。本地测试工作正常,github 部署失败,错误消息完全相同。 我认为我的配置文件或 gemfile 中缺少某些内容,但一切都很好。 其实只是我的仓库结构有问题。

当我克隆我的 github-pages 存储库时,我在存储库中创建了新的 jekyll 项目,这是我的错误。 Github 不需要中间文件夹。

我的结构是这样的:

username.github.io
|_ jekyll-project-name
  |_ _layouts
  |_ _includes
  |_ _sass
  |_ index.html

github搭建的结构应该是这样的:

username.github.io
|_ _layouts
|_ _includes
|_ _sass
|_ index.html

也许对你来说也是同样的问题。

为了以防万一,请检查您的 gemfile 中是否有这个:

# gem "jekyll"
gem 'github-pages', group: :jekyll_plugins

您的引导导入不需要 site.baseurl。

【讨论】:

    猜你喜欢
    • 2021-12-27
    • 1970-01-01
    • 2022-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多