Jekyll + GitHub Pages搭建博客和Academic Page
Jekyll + GitHub Pages搭建博客和Academic Page
Three Reference Websites
- Automated Deployment - Jekyll • Simple, blog-aware, static sites
- About GitHub Pages and Jekyll - GitHub Docs
- The fastest and easiest way to install Ruby on a Mac in 2023
解决Mac上的Ruby权限问题
Jekyll是基于Ruby的,所以需要先安装Ruby,不能使用Mac自带的Ruby,否则在通过 gem install jekyll
时可能会遇到无法访问相应文件夹的问题。常见错误如下:
1
2
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
解决方法:
- 更新Homebrew
1
brew update && brew doctor
按照
brew doctor
提供的提示进行更新,确保你的Xcode已经升级到14.2及以上,因为Command Line Tool包含一些关键更新,否则可能无法解决该问题。 - 安装和配置Ruby 按照这篇文章的
step by step
操作指南,成功更换Ruby版本,并正确安装Jekyll。
安装Jekyll
1
2
3
4
5
6
7
8
9
10
11
# 安装 Jekyll 和 Bundler
gem install jekyll bundler
# 创建 Jekyll 项目
jekyll new my_blog
# 进入项目目录
cd my_blog
# 运行本地服务器
bundle exec jekyll serve
访问 http://localhost:4000/
,如果能正常打开,则说明Jekyll安装成功。
部署到GitHub Pages
- 在GitHub上创建一个新的仓库,命名为
your_username.github.io
- 在本地Jekyll项目目录中,初始化Git仓库并推送到GitHub:
1
2
3
4
5
6
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/your_username/your_username.github.io.git
git push -u origin main
- 启用GitHub Pages,在GitHub仓库的
Settings > Pages
中,选择main
分支并保存。 - 访问
https://your_username.github.io/
,如果一切配置正确,你的Jekyll博客应该已经成功上线!
This post is licensed under CC BY-NC 4.0 by the author.