Win10建云笔记用的简易博客Github+Jekyll

前言

花了半天时间建的博客,博客链接:https://allrobot.github.io/Study-Blog/

写一个Github建博客指南,防以后忘记

若以下内容过时导致失效,请查阅Jekyll文档

Jekyll文档:https://jekyllrb.com/docs/
以及https://jekyllrb.com/docs/themes/

安装环境

下载的6个程序包,需设系统的环境变量...安装教程自行搜索,弄完了输入版本指令验证是否安装成功

打开CMD安装jekyllbundler

 # gem安装依赖RubyGems实现
 gem install jekyll bundler
 # 输入查询版本指令,查看是否安装成功
 jekyll -v
 bundler -v

安装与验证

下载Github桌面版

https://desktop.github.com/

点击File-New repository(博客仓库)

随便填点,点击Create repository按钮

Jekyll创建简易博客

CMD跳到D:\test目录

 cd /d D:\test

Github建立的项目文件夹

记得设为Public,否则私人仓库开通Github博客需要付费的

输入指令新建Jekyll项目

 # test为github仓库名,若没有则新建文件夹
 jekyll new test

新建jekyll项目

此时,test文件夹多了几个文件
Jekyll新建的项目

添加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 ViewerMarkdown All in One之类的小插件,边写边预览

要修改标题,可以改md文件里的title....
博客支持Markdown语法,LaTex 数学公式...

写完文章,Git同步就可以了,很方便的

posted @ 2022-02-06 22:04  平凡的玩家  阅读(75)  评论(0编辑  收藏  举报