6.19-搭建github博客
搭建github博客
前言
- 本来准备在CSDN上建个博客,后来为了能够更加自动化,还是在GitHub Pages 上弄一个
步骤
准备
# 对于ubuntu 16.04
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
# 重启terminal
nvm install node
npm install -g hexo-cli
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install -g hexo-cli
- 对于Windows
- 安装git for windows,接下来需要使用git bash
- 安装Node.js
npm install -g hexo
- 修改npm的安装源
npm -registry http://registry.cnpmjs.org info underscore
- 建立github.io项目
本地建站
mkdir zsBlog
cd ./zsBlog/
hexo init
第一个页面
hexo generate
hexo server
Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
- 进入浏览器访问页面即可
创建一个页面并预览
hexo new "Zhensheng的第一个博客"
Created: ~/zsBlog/source/_posts/Zhensheng的第一个博客.md
cd source/_posts
code ./Zhensheng的第一个博客
hexo generate
hexo server
- 浏览器访问预览
设置一个主题
cd ~/zsBlog
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
code ./_config.yml
- 更改这一行
theme: yilia
主题配置
cd themes/yilia
code ./_config.yml
deploy:
type: git
repo: git@github.com:ZhenshengLee/ZhenshengLee.github.io.git
branch: master
- 更新并部署
hexo clean
hexo generate
hexo deploy
deploy 没反应
sudo npm install hexo-deployer-git --save
Hexo配置
添加toc支持
- 使用方法:添加
<!-- toc -->
cd ./zsBlog
# 到根目录
npm install hexo-toc --save
subl /home/zs/Nutstore/zsBlog/_config.yml
toc:
maxDepth: 3
首页显示摘要
- 如果你需要主页显示文章全部内容,只显示摘要的话,就在文章中加一行