使用GitHub Pages 和 Hexo 搭建博客

 

心水Hexo的NexT主题很久了,时不时看的小土刀的博客用的就是NexT主题。网上随处可见的非常Elegant的博客用的也都是NexT主题。这使得我非常想要一个NexT主题的博客,最近终于有时间实现这一愿望了。

Step 1 GitHub Pages

创建Repository

在Github创建一个Repository,名字格式是username.github.io

打开博客

点击Settings > GitHub Pages > Choose a theme,这里选择Cayman。

在它跳转的界面点击 Commit changes 按钮,这样网站就可以访问了。

打开https://yalinma.github.io/ ,确认网站可以正常打开。

Step 2 Hexo

Hexo是一个简单、强大的博客框架。

安装Hexo

npm install hexo-cli -g
hexo init blog
cd blog
npm install
hexo server

打开http://localhost:4000/ ,确认Hexo安装OK。

安装Next主题

使用以下命令,安装NexT主题。

git clone https://github.com/theme-next/hexo-theme-next themes/next

修改Hexo配置文件 _config.yml

theme: next

运行hexo server,打开http://localhost:4000/ ,确认主题安装OK。

Step 3 首次发布内容

在Hexo上创建内容

生成一个文件名为使用GitHub Pages 和 Hexo 搭建博客的markdown文件。

hexo new "使用GitHub Pages 和 Hexo 搭建博客"

编辑内容

在电脑上打开blog > source >_posts,打开使用GitHub Pages 和 Hexo 搭建博客.md,往里面写入内容。

部署Hexo中的内容到Github

安装hexo-deployer-git

npm install hexo-deployer-git --save

修改_config.yml文件

deploy:
type: git
repo: git@github.com:yalinma/yalinma.github.io.git #这里使用的是SSH repo url,原因见参考[3]
branch: master

部署到Github

./node_modules/.bin/hexo clean && ./node_modules/.bin/hexo deploy

打开你的博客https://yalinma.github.io/ ,确认内容发布OK。

Step 4 平时发布内容

只需要创建、编辑及部署到Github。

创建内容

hexo new "你的文章标题"

编辑内容

在电脑上打开blog > source >_posts,打开你的文章标题.md,往里面写入内容。

部署到Github

./node_modules/.bin/hexo clean && ./node_modules/.bin/hexo deploy

打开你的博客https://yalinma.github.io/ ,确认发布OK。

参考

  1. GitHub Pages 搭建教程
  2. Deployment
  3. Github deploy fails if you have 2-factor auth enabled #500

 

如何在触控板上轻松拖动文件?

 

以前总是拿两根手指在电脑触控板上拖动文件,按得好累。中间手没力气了,还要再重新拖动一次,非常麻烦。最近学会了三指拖移的方式拖动文件,觉得非常方便。

打开System Preferences > Accessibility > Mouse & Trackpad > Trackpad Options,勾选Enable dragging,选择three finger drag。

这样你就可以轻松的用三根手指拖动文件了。

 

使用触控板一键滑动锁定电脑

 

以前只会用快捷键 ⌃⌘Q(Control + Command + Q)来锁定MacBook笔记本。最近学会了在触控板上轻轻滑动一键锁定电脑,觉得非常方便。
打开System Preferences > Mission Control > Hot Corners,在左下角设置Lock Screen。

之后就可以在触控板上轻轻一滑,锁定电脑,超酷超方便。