Adding Bootstrap to Jekyll

后端 未结 3 374
遇见更好的自我
遇见更好的自我 2020-12-04 14:31

I\'m new to Jekyll and would like to pull in some of the Twitter Bootstrap functionality. Has anyone done this and, if so, do you have any advice? I would have gone with Jek

3条回答
  •  借酒劲吻你
    2020-12-04 15:26

    As Jekyll natively supports sass, you can use bootstrap-sass.

    I personally install it with the bower install bootstrap-sass command.

    This installs Bootstrap and Jquery in the bower_components folder.

    Configuration

    In your _config.yml add :

    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: compressed
    

    Javascript

    If you want to use javascript, in your _includes/footer.html add :

    
    
    

    Use

    In css/main.scss delete previous content and add

    ---
    # 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";
    

    You can see all variables available in bower_components/bootstrap-sass/assets/stylesheets/bootstrap/_variables.scss

    You can remove you old _sass folder.

    Now your css file is generated at each build.

提交回复
热议问题