我是Jekyll的新手,我想引入一些Twitter Bootstrap功能。有没有人这样做过,如果有,你有什么建议吗?我会选择Jekyll-Bootstrap,但不再支持它。我已经建立了我的Jekyll网站,我希望有一种方法来拉在Bootstrap。
发布于 2015-02-26 16:54:08
因为Jekyll本身就支持sass,所以你可以使用bootstrap-sass。
我亲自使用bower install bootstrap-sass命令安装它。
这将在bower_components文件夹中安装Bootstrap和Jquery。
配置
在您的_config.yml中添加:
sass:
# loading path from site root
# default to _sass
sass_dir: bower_components/bootstrap-sass/assets/stylesheets
# style : nested (default), compact, compressed, expanded
# :nested, :compact, :compressed, :expanded also works
# see http://sass-lang.com/documentation/file.SASS_REFERENCE.html#output_style
# on a typical twitter bootstrap stats are :
# nested 138,7kB, compact 129,1kB, expanded 135,9 kB, compressed 122,4 kB
style: compressedJavascript
如果要使用javascript,请在您的_includes/footer.html中添加:
<script src="{{ site.baseurl }}/bower_components/jquery/dist/jquery.min.js"></script>
<script src="{{ site.baseurl }}/bower_components/bootstrap-sass/assets/javascripts/bootstrap.min.js"></script>使用
在css/main.scss中,删除以前的内容并添加
---
# Only the main Sass file needs front matter (the dashes are enough)
---
@charset "utf-8";
/* path to glyphicons */
$icon-font-path: "/bower_components/bootstrap-sass/assets/fonts/bootstrap/";
/* custom variable */
$body-bg: red;
/* any style customization must be before the bootstrap import */
@import "bootstrap";您可以在bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_variables.scss中查看所有可用的变量
您可以删除旧的_sass文件夹。
现在,在每次构建时都会生成css文件。
发布于 2019-11-05 04:17:15
Bootstrap 4.3.1和Jekyll 4.0的
更新
您可以使用Bunder键将BS安装到您的站点中
bundle install bootstrap添加到gem文件中:
gem 'bootstrap', '~> 4.3.1'获取BS的路径
bundle info bootstrap将该路径添加到_config.yml
sass:
load_paths:
- _sass
- C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootstrap-4.3.1/assets/stylesheets也可以改为添加相对路径。
最后,将引导程序添加到style.scss
@import "bootstrap";发布于 2017-10-16 02:02:52
Bootstrap 4 Beta版更新
As Bootstrap 4 Beta now runs on Sass,你可以使用“官方”的bower包。
下面是我所做的:
1.使用Bower安装Bootstrap
将引导程序及其依赖项安装到bower_components文件夹的bower install bootstrap#v4.0.0-beta --save。
2.配置
在_config.yml中,我更改了Sass文件夹,并从处理中排除了bower_components:
sass:
sass_dir: assets/css
# Exclude from processing.
exclude:
- bower_components3. Sass
我按如下方式更改了assets/css/main.scss:
---
# Only the main Sass file needs front matter (the dashes are enough)
---
@charset "utf-8";
@import "variables"; // (2)
@import "../../bower_components/bootstrap/scss/bootstrap"; // (1)
// Import other styling below
// ...(1)注意,第二个import语句必须相对于在_config.yml中指定的Sass目录。因为我选择它作为包含main.scss的文件夹,所以您最喜欢的集成开发环境(例如WebStorm)中的资源链接不会断开。
(2)为了覆盖Bootstrap Sass变量,我创建了assets/css/_variables.scss,它必须在Bootstrap库之前导入。
4. Javascript
由于我没有找到使用附带到bower_components中的JS的方法,所以我选择包含CDN版本的as proposed by Bootstrap
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>https://stackoverflow.com/questions/28733425
复制相似问题