• jekyll搭建博客


    jekyll 博客安装

    为什么要用jekyll
    jekyll是一个简单的免费的Blog生成工具,类似WordPress。但是和WordPress又有很大的不同,原因是jekyll只是一个生成静态网页的工具,不需要数据库支持。但是可以配合第三方服务,例如Disqus。最关键的是jekyll可以免费部署在Github上,而且可以绑定自己的域名。

    语言支持

    • YAML一个可读性高,用来表达数据序列化的格式
    • Liquid Liquid 是一门用 Ruby 编写的开源模板语言,

    1、ruby -v
    查看你的机器是否安装了ruby ,成功如下

    ruby 2.3.7p456 (2018-03-28 revision 63024) 
    [universal.x86_64-darwin17]
    

    2、gem install jekyll
    RubyGems 是 Ruby 的一个包管理器,会下载 依赖文件,我执行的时候报错看提示像环境变量的问题。

    Building native extensions.  This could take a while...
    ERROR:  Error installing jekyll:
    ERROR: Failed to build gem native extension.
    current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.11.3/ext/ffi_c
    

    解决方式参考

    3 sudo gem install jekyll 命令执行报错

    Building native extensions.  This could take a while...
    Successfully installed sassc-2.2.1
    Fetching: jekyll-sass-converter-2.0.1.gem (100%)
    ERROR:  Error installing jekyll:
    	jekyll-sass-converter requires Ruby version >= 2.4.0.
    

    解决方式 重新指定镜像地址 更新gem

    gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
    sudo gem update --system
    

    重新安装ruby
    brew install ruby执行完成之后需要手动执行 export

    You may want to add this to your PATH.
    
    ruby is keg-only, which means it was not symlinked into /usr/local,
    because macOS already provides this software and installing another version in
    parallel can cause all kinds of trouble.
    
    If you need to have ruby first in your PATH run:
      echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
    
    For compilers to find ruby you may need to set:
      export LDFLAGS="-L/usr/local/opt/ruby/lib"
      export CPPFLAGS="-I/usr/local/opt/ruby/include"
    

    4、执行完成之后查看 ruby -v是否大于等于2.4版本

    5、执行gem安装Jekyll安装 Jekyll

    6、zsh: command not found: jekyll报错
    执行sudo gem install --user-install bundler jekyll之后还是报错如下:
    WARNING: You don't have /Users/你的用户名/.gem/ruby/2.6.0/bin in your PATH,
    这个时候加入到path
    export PATH=${PATH}:/Users/tonyyang/.gem/ruby/2.6.0/bin
    此刻再执行jekyll -v, 显示成功。

    7、跑到项目目录底下执行 jekyll 报错

    	19: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler.rb:107:in `setup'
    	18: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/runtime.rb:20:in `setup'
    	17: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/runtime.rb:108:in `block in definition_method'
    	16: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:226:in `requested_specs'
    	15: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:237:in `specs_for'
    	14: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:170:in `specs'
    	13: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:247:in `resolve'
    	12: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:744:in `converge_locked_specs'
    	11: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:744:in `each'
    	10: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:758:in `block in converge_locked_specs'
    	 9: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git.rb:167:in `specs'
    	 8: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/path.rb:100:in `local_specs'
    	 7: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git.rb:200:in `load_spec_files'
    	 6: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/path.rb:163:in `load_spec_files'
    	 5: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/path.rb:126:in `expanded_path'
    	 4: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git.rb:93:in `install_path'
    	 3: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git.rb:225:in `revision'
    	 2: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git/git_proxy.rb:64:in `revision'
    	 1: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git/git_proxy.rb:192:in `find_local_revision'
    /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git/git_proxy.rb:235:in `allowed_in_path': The git source git://github.com/flori/json.git is not yet checked out. Please run `bundle install` before trying to start your application (Bundler::GitError)
    

    提示很清楚了要执行bundle install命令。

    8、jekyll new sss重新创建一个名为sss的项目

    Running bundle install in /Users/tonyyang/IdeaProjects/sss...
    Bundler: Fetching gem metadata from https://gems.ruby-china.com/............
    Bundler: Fetching gem metadata from https://gems.ruby-china.com/..
    Bundler: Resolving dependencies...
    Bundler: Using public_suffix 4.0.2
    Bundler: Using addressable 2.7.0
    Bundler: Using bundler 2.1.3
    Bundler: Using colorator 1.1.0
    Bundler: Using concurrent-ruby 1.1.5
    Bundler: Using eventmachine 1.2.7
    Bundler: Using http_parser.rb 0.6.0
    Bundler: Using em-websocket 0.5.1
    Bundler: Using ffi 1.11.3
    Bundler: Using forwardable-extended 2.6.0
    Bundler: Using i18n 1.7.0
    Bundler: Using sassc 2.2.1
    Bundler: Using jekyll-sass-converter 2.0.1
    Bundler: Using rb-fsevent 0.10.3
    Bundler: Using rb-inotify 0.10.1
    Bundler: Using listen 3.2.1
    Bundler: Using jekyll-watch 2.2.1
    Bundler: Using kramdown 2.1.0
    Bundler: Using kramdown-parser-gfm 1.1.0
    Bundler: Using liquid 4.0.3
    Bundler: Using mercenary 0.3.6
    Bundler: Using pathutil 0.16.2
    Bundler: Using rouge 3.14.0
    Bundler: Using safe_yaml 1.0.5
    Bundler: Using unicode-display_width 1.6.0
    Bundler: Using terminal-table 1.8.0
    Bundler: Using jekyll 4.0.0
    Bundler: Using jekyll-feed 0.13.0
    Bundler: Using jekyll-seo-tag 2.6.1
    Bundler: Using minima 2.5.1
    Bundler: Bundle complete! 6 Gemfile dependencies, 30 gems now installed.
    Bundler: Use `bundle info [gemname]` to see where a bundled gem is installed.Following files may not be writable, so sudo is needed:
    Bundler: /usr/local/lib/ruby/gems/2.6.0/bundler.lock
    New jekyll site installed in /Users/tonyyang/IdeaProjects/sss
    

    9、cd 到sss项目目录下执行jekyll serve命令

    Configuration file: /Users/tonyyang/IdeaProjects/sss/_config.yml
                Source: /Users/tonyyang/IdeaProjects/sss
           Destination: /Users/tonyyang/IdeaProjects/sss/_site
     Incremental build: disabled. Enable with --incremental
          Generating...
           Jekyll Feed: Generating feed for posts
                        done in 0.517 seconds.
     Auto-regeneration: enabled for '/Users/tonyyang/IdeaProjects/sss'
        Server address: http://127.0.0.1:4000/
      Server running... press ctrl-c to stop.
    

    显示成功,通过http://localhost:4000/访问
    在这里插入图片描述
    以上就是jekyll搭建个人博客网站内容。

  • 相关阅读:
    Java路径问题终于解决方式—可定位全部资源的相对路径寻址
    易学设计模式看书笔记(2)
    js算法:分治法-棋盘覆盖
    [NIO]dawn之Task具体解释
    C#高级编程五十八天----并行集合
    [Swift通天遁地]九、拔剑吧-(12)创建Preview-Transition图像预览界面
    [Swift通天遁地]九、拔剑吧-(11)创建强大的Pinterest风格的瀑布流界面
    [Swift通天遁地]九、拔剑吧-(10)快速创建美观的聊天界面:可发送文字、表情、图片
    [Swift通天遁地]九、拔剑吧-(9)创建支持缩放、移动、裁切的相机视图控制器
    [Swift通天遁地]九、拔剑吧-(8)创建气泡式页面切换效果
  • 原文地址:https://www.cnblogs.com/tonyY/p/12150589.html
Copyright © 2020-2023  润新知