MAC下Jekyll环境搭建

1.Jekyll简介

Jekyll 是一个简单的博客形态的静态站点生产机器。它有一个模版目录,其中包含原始文本格式的文档,通过 Markdown (或者 Textile) 以及 Liquid 转化成一个完整的可发布的静态网站,你可以发布在任何你喜爱的服务器上。Jekyll 也可以运行在 GitHub Page 上,也就是说,你可以使用 GitHub 的服务来搭建你的项目页面、博客或者网站,而且是完全免费的。

2.安装Jekyll

安装 Jekyll首先需要Ruby环境的支持,部分Mac自带,没有则需要安装

2.1.安装Rvm

Rvm是一个命令行工具,可以提供一个便捷的多版本 Ruby 环境的管理和切换

在控制台输入以下命令,然后回车:

$ curl -sSL https://get.rvm.io | bash -s stable

控制台输出如下:

Downloading https://github.com/rvm/rvm/archive/1.29.7.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc',
but no GPG software exists to validate it, skipping.
省略.....
in all your open shell windows, in rare cases you need to reopen all shell windows.

切换Ruby镜像地址:

$ gem sources --remove https://rubygems.org/
$ gem sources --add https://gems.ruby-china.com/
$ gem sources -l

2.2.安装Ruby

列出可安装的版本信息(此处安装的是2.6.0):

$ rvm list known

安装一个ruby版本:

$ rvm install 2.6.0

如果想设置为默认版本,可以用这条命令来完成:

$ rvm use 2.4.0 —default

也可执行安装命令的时候直接设置为默认版本:

$ rvm install 2.6 —default

若提示以下信息,则是缺失软件包的管理器,需要安装Command-Line Tools

No binary rubies available for: osx/10.13/x86_64/ruby-2.6.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
touch: /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress: Permission denied
rm: /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress: Permission denied

执行以下命令来安装Command-Line Tools:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

静静等待,控制台输出以下信息则是安装成功:

/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The Xcode Command Line Tools will be installed.

Press RETURN to continue or any other key to abort
==> Searching online for the Command Line Tools
==> /usr/bin/sudo /usr/bin/touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress

==> Installing Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.1
==> /usr/bin/sudo /usr/sbin/softwareupdate -i Command\ Line\ Tools\ (macOS\ High\ Sierra\ version\ 10.13)\ for\ Xcode-10.1
Software Update Tool
Downloading Command Line Tools (macOS High Sierra version 10.13) for Xcode
Downloaded Command Line Tools (macOS High Sierra version 10.13) for Xcode
Installing Command Line Tools (macOS High Sierra version 10.13) for Xcode

Done with Command Line Tools (macOS High Sierra version 10.13) for Xcode
Done.
==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools
==> Downloading and installing Homebrew...
remote: Enumerating objects: 24, done.
remote: Counting objects: 100% (24/24), done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 119598 (delta 7), reused 18 (delta 2), pack-reused 119574
Receiving objects: 100% (119598/119598), 28.28 MiB | 99.00 KiB/s, done.
Resolving deltas: 100% (87381/87381), done.
From https://github.com/Homebrew/brew
省略.....
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Next steps:
- Run `brew help` to get started
- Further documentation:
    https://docs.brew.sh

再次执行Ruby安装命令:

$ rvm install 2.6 —default

控制台输出以下信息则是安装成功:

Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.13/x86_64/ruby-2.6.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system......
Installing required packages: autoconf, automake, libtool, pkg-config, coreutils, libyaml, readline, libksba, openssl@1.1..............
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
省略.....
ruby-2.6.0 - #generating default wrappers.......
ruby-2.6.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.0 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri

查看Ruby 版本:

$ ruby -v
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin17]

2.3.安装Jekyll

通过上面的步骤,基础环境搭建好了,开始安装Jekyll,输入以下命令:

$ gem install jekyll

控制台输出如下:

Fetching addressable-2.6.0.gem
Fetching colorator-1.1.0.gem
Fetching http_parser.rb-0.6.0.gem
Fetching em-websocket-0.5.1.gem
Fetching public_suffix-3.0.3.gem
Fetching eventmachine-1.2.7.gem
Fetching concurrent-ruby-1.1.4.gem
Fetching i18n-0.9.5.gem
Fetching rb-fsevent-0.10.3.gem
Fetching ffi-1.10.0.gem
Fetching rb-inotify-0.10.0.gem
Fetching sass-listen-4.0.0.gem
Fetching sass-3.7.3.gem
Fetching jekyll-sass-converter-1.5.2.gem
省略.....
Parsing documentation for jekyll-3.8.5
Installing ri documentation for jekyll-3.8.5
Done installing documentation for public_suffix, addressable, colorator, http_parser.rb, eventmachine, em-websocket, concurrent-ruby, i18n, rb-fsevent, ffi, rb-inotify, sass-listen, sass, jekyll-sass-converter, ruby_dep, listen, jekyll-watch, kramdown, liquid, mercenary, forwardable-extended, pathutil, rouge, safe_yaml, jekyll after 43 seconds
25 gems installed

安装成功后,查看版本号:

$ jekyll -v
jekyll 3.8.5

3.Jekyll常用命令

Jekyll安装好后,就可以在命令行中使用Jekyll命令了,有以下用法:

$ jekyll build
# => 当前文件夹中的内容将会生成到 ./site 文件夹中
$ jekyll build --destination <destination>
# => 当前文件夹中的内容将会生成到目标文件夹<destination>中
$ jekyll build --source <source> --destination <destination>
# => 指定源文件夹<source>中的内容将会生成到目标文件夹<destination>中
$ jekyll build --watch
# => 当前文件夹中的内容将会生成到 ./site 文件夹中,
#    查看改变,并且自动再生成

build的时候如遇以下错误,则是缺少依赖插件包:

Dependency Error: Yikes! It looks like you don't have jekyll-paginate or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'cannot load such file -- jekyll-paginate' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
jekyll 3.8.5 | Error:  jekyll-paginate

输入以下命令安装:

$ gem install jekyll-paginate

Jekyll 同时也集成了一个开发用的服务器,可以让你使用浏览器在本地进行预览。

$ jekyll serve
# => 一个开发服务器将会运行在 http://localhost:4000/

$ jekyll serve --detach
# => 功能和`jekyll serve`命令相同,但是会脱离终端在后台运行。
#    如果你想关闭服务器,可以使用`kill -9 1234`命令,"1234" 是进程号(PID)
#    如果你找不到进程号,那么就用`ps aux | grep jekyll`命令来查看,然后关闭

$ jekyll serve --watch
# => 和`jekyll serve`相同,但是会查看变更并且自动再生成

还有一些可以配置的配置选项.很多配置选项既可以在命令行中作为标识(flags)设定,也可以在源文件根目录中的 _config.yml 文件中进行设定。Jekyll 会自动加载这些配置。比如你在你的 _config.yml 文件中添加了下面几行:

destination: _deploy
source: _source

那么就等价于执行了以下两条命令:

$ jekyll build
$ jekyll build --source _source --destination _deploy

详细配置见官网配置列表:https://www.jekyll.com.cn/docs/configuration/

原文地址:https://blog.csdn.net/chen_changying/article/details/88093559

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


现在给大家介绍一下如何查询MAC的生产日期,希望对你查询MAC的生产日期操作有所帮助。
1、点击【编辑虚拟机设置】,转到【CD/DVD (SATA)】,选中【使用 ISO 映像文件】复选框,点击【浏览】,找到已经准备好的 MacOS Ventura 镜像;4、客户机操作系统下,选择【Apple Mac OS X】,版本选择大家需要的【macOS版本】,再点击【下一步】;7、完成【抹掉】后,左上角关闭该窗口,返回上一界面,选择【Install macOS】,正式进入苹果系统安装流程;1、打开 Vmware Workstation,然后点击左上角的【文件】,打开的下拉项中,选择【新建虚拟机】;
注意:用哪个版本的 Python 运行安装脚本,pip 就被关联到哪个版本。一般情况 pip 对应的是 Python 2.7,pip3 对应的是 Python 3.x。pip介绍:pip 是 Python 包管理工具,该工具提供了对Python 包的查找、下载、安装、卸载的功能。1.打开后输入python3确定电脑上是否已安装python3,如果输入python是查看mac上的自带版本。如果你在 python.org 下载最新版本的安装包,则是已经自带了该工具。如下图是已经成功安装pip的状态。
Mac 安装nvm
Mac(M1)安装VMware虚拟机及Linux系统
Mac 如何安装 Telnet,mac安装telnet命令
是不是对键盘输入厌烦了?那你可以试试语音输入。 你可以按照下面的步骤打开Mac的语音输入功能。 以 macOS Catalina 为例: Step 1. 点击屏幕左上角的图标,点击【系统偏好设置】。
1.clean my Mac&#160;x 2.Cleaner One Pro 3.App Cleaner
按caps lock键。 CapsLock键,短按切换中英文,长按切换大小写。
windows: 1.PowerToys 2.不用软件进行分屏 Windows 10技巧1:窗口1/4分屏 - Acer Community 介绍说明 从Win7时代开始,微软便引入了屏幕热区概念,即
https://zhuanlan.zhihu.com/p/111111684 下载地址: https://www.smoothscroll.net/mac/
https://support.apple.com/zh-cn/guide/imac/apd2e7352054/mac 浏览:24 英寸&#160;iMac 24 英寸&#160;iMac 比以往更个
在Mac自带的中文输入法中,“反斜杠”键(“\”)就是顿号。
1.系统偏好设置。 2和3步如下图: 注意:在设置后,启用capslock大写的时候,需要长按capslock键。
Typora是一款轻便简洁的Markdown编辑器,支持即时渲染技术,这也是与其他Markdown编辑器最显著的区别。即时渲染使得你写Markdown就想是写Word文档一样流畅自如,不像其他编辑器的有编辑栏和显示栏。简洁美观实时预览扩展语法跨平台免费Typora现在收费,但你仍然可以在官方网站上找到历史版本。虽然新版本仍然值得收费,但免费版本仍然可以使用。httpshttpshttpshttpshttpshttpshttpshttps。......
Mac M1安装Centos7
连接为官方下载链接, 直接复制MD5可迅雷下载亲测可用, 和付费版使用体验无差别.1. Windows 64bithttps://download.typora.io/windows/typora-setup-x64-0.11.18.exeMD5:12F96372BEE2951ACF5627EA28F8A389**2. Window 32bit **https://download.typora.io/windows/typora-setup-ia32-0.11.18.exeMD5:F5036
ubuntu22.04 、系统安装、win双系统、Ubuntu分区、Ubuntu优化、美化gnome tweaks,扩展、macos、搜狗输入法、wps字体、微信安装、navicat15、java开发环境搭建、idea 输入法问题处理、双系统问题、github慢等等。史上最全保姆级Ubuntu使用教程
MAC怎么获取文件路径 MAC获取文件路径的四种方法