进入你的网站目录:
cd ~/websites/moonaurora.github.io
启动本地预览:
bundle exec jekyll serve
然后浏览器打开:
http://127.0.0.1:4000
你修改文件后,Jekyll 通常会自动重新生成,刷新浏览器就能看到变化。
如果你是在服务器环境、想让别的设备也能访问,可以用:
bundle exec jekyll serve –host 0.0.0.0 –port 4000 本地改完后发布到线上要运行什么
每次改完,最常用就是这四步:
cd ~/websites/moonaurora.github.io git status git add . git commit -m “Update website content” git push origin main
然后等 GitHub Pages 自动重新部署。
再打开:
https://moonaurora.github.io
刷新看线上效果。
最推荐你以后记住的完整工作流
- 进入项目目录 cd ~/websites/moonaurora.github.io
- 本地预览 bundle exec jekyll serve
- 修改文件
比如改:
_config.yml
_pages/about.md
_publications/
_portfolio/
images/
files/
- 浏览器刷新看本地效果
看 http://127.0.0.1:4000
- 满意后提交并推送 git add . git commit -m “Describe your update” git push origin main
- 等 GitHub Pages 自动更新
最后访问:
https://moonaurora.github.io 哪些情况需要重新运行 bundle exec jekyll serve
一般来说:
你第一次打开项目,需要运行一次
你关闭终端后,下次要重新运行
有时改了 _config.yml 后,自动热更新不完全,最好 Ctrl+C 停掉再重新启动一次
也就是:
Ctrl + C bundle exec jekyll serve 哪些情况不需要重新 bundle install
bundle install 不是每次都要跑。 只有这些情况才需要:
第一次在这台 Ubuntu 上配置环境
Gemfile 或 Gemfile.lock 变了
依赖丢了
终端提示缺少 gem
平时改网页内容,不需要反复 bundle install。
以后最常用的 3 条命令
你基本记住这三个就够了:
bundle exec jekyll serve git add . git commit -m “xxx” && git push origin main 给你一个最省事的记忆版本 只本地看 bundle exec jekyll serve 改完发到线上 git add . git commit -m “update” git push origin main
