LoginSignup
0
0

More than 1 year has passed since last update.

jekyll④bootstrap設定

Last updated at Posted at 2022-06-15

bootstrapをvendor以下にダウンロード

以下の方法だと、共同開発の際にrubyのバージョンを統一する必要があったり、vendor以下(不要なファイル)もgithubにプッシュしないといけないのであまりオススメできない

①bootstrapをダウンロードする

Gemfileに以下を記入し、bundle installする
(バージョンを書かなくても最新のbootstrapがダウンロードされる)

gem 'bootstrap'
bundle install

vendor/bundle/ruby/2.7.0/gems/bootstrap-5.1.3がダウンロードされていることを確認する
スクリーンショット 2022-06-15 15.09.07.png

②bootstrap.scssを設定

assets/css/style.cssに@importを入力

@import "../vendor/bundle/ruby/2.7.0/gems/bootstrap-5.1.3/assets/stylesheets/_bootstrap";

③ビルドされていることを確認する

_site/assets/css/style.cssにbootstrap.scssの内容が生成されているか確認する

$bundle exec jekyll build

スクリーンショット 2022-06-15 15.28.23.png

④githubにプッシュする際.gitignoreのvendorの記述を削除

削除しないと、vendor以下がgithubにアップされないためビルドされずbootstrapで組んだレイアウトが崩れるので注意する

_site
.sass-cache
.jekyll-cache
.jekyll-metadata
vendor←削除

bootstrap.scssのファイルを_sass以下にダウンロード

こちらの方法だと、bootstrap.scssのカスタムもしやすく、共同開発の際にrubyのバージョンを統一や、vendor以下(不要なファイル)もgithubにプッシュする必要がない

①bootstrapダウンロードし、_sass以下にダウンロードしたbootstrapファイルを入れる

bootstrapをダウンロード
スクリーンショット 2022-06-15 15.44.39.png

②_sass/_custom.scssを作成し、importする

@import'../_sass/bootstrap-file/bootstrap';

③assets/css/style.scssにもimportする

---
---
@import '../_sass/custom';

④ビルドされていることを確認する

_site/assets/css/style.cssにbootstrap.scssの内容が生成されているか確認する

$bundle exec jekyll build
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0