Win10建云笔记用的简易博客Github+Jekyll
前言
花了半天时间建的博客,博客链接:https://allrobot.github.io/Study-Blog/
写一个Github建博客指南,防以后忘记
若以下内容过时导致失效,请查阅Jekyll文档
Jekyll文档:https://jekyllrb.com/docs/
以及https://jekyllrb.com/docs/themes/
安装环境
- Ruby
https://rubyinstaller.org/downloads/ - RubyGems
https://rubygems.org/pages/download - NodeJS
https://nodejs.org/en/download/ - Python3
https://www.python.org/downloads/ - GCC和Make
gcc:https://nchc.dl.sourceforge.net/project/mingw/Installer/mingw-get-setup.exe
make:https://cmake.org/
下载的6个程序包,需设系统的环境变量...安装教程自行搜索,弄完了输入版本指令验证是否安装成功
打开CMD安装jekyll和bundler
# gem安装依赖RubyGems实现
gem install jekyll bundler
# 输入查询版本指令,查看是否安装成功
jekyll -v
bundler -v

下载Github桌面版
点击File-New repository(博客仓库)

随便填点,点击Create repository按钮

Jekyll创建简易博客
CMD跳到D:\test目录
cd /d D:\test
Github建立的项目文件夹
记得设为Public,否则私人仓库开通Github博客需要付费的
输入指令新建Jekyll项目
# test为github仓库名,若没有则新建文件夹
jekyll new test

此时,test文件夹多了几个文件

添加webrick,启动本地浏览器
如果webrick等待时间长了,按ctrl+c退出,在输入一次
bundle add webrick
jekyll serve

开启本地服务
jekyll serve

浏览器输入localhost:4000

确保所有文件存放Jekyll站点目录下,需把主题文件夹的CSS样式表等文件放入仓库博客
打开_config.yml文件
title: Your awesome title
email: your-email@example.com
description: >- # this means to ignore newlines until "baseurl:"
Write an awesome description for your new site here. You can edit this
line in _config.yml. It will appear in your document head meta (for
Google search results) and in your feed.xml site description.
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: jekyllrb
github_username: jekyll
# Build settings
theme: minima
plugins:
- jekyll-feed
theme指定minima主题,可以指定想要的主题,要发布到Github Pages仅修改_config.yml即可
只是要删除上面的theme: minima,因为Github不加载Gemfile对主题gem的引用
然后添加baseurl:"/仓库项目名"如果不添加,Github博客不会加载CSS样式表
我这儿是加了'baseurl: "/test"
搜索主题文件夹并复制到仓库目录
bundle info --path minima


Github Pages开启页面并保存
Github桌面版同步到Giuhub,点击View on GitHub,前往Settings-Pages




建立的简易博客:https://allrobots.github.io/test/
更换主题
可供下载的主题:http://jekyllthemes.org/
如果有更换主题需求,保留配置、文档、引用图片即可,注意对比
_config.yml配置,有些主题不支持特定配置(Jekyll主题不一样,插件等自然不同)
关于编写文章
D:\test\test_posts复制里面的示例文件2022-02-06-welcome-to-jekyll副本.markdown重命名为2022-02-06-article1.markdown

建议开启jekyll serve本地预览,边写边预览
或VS Code下个Office Viewer、Markdown All in One之类的小插件,边写边预览
要修改标题,可以改md文件里的title....
博客支持Markdown语法,LaTex 数学公式...
写完文章,Git同步就可以了,很方便的


浙公网安备 33010602011771号