第一步 安装Node.js
在 Windows 环境下安装 Node.js :到nodejs.org/en/download… 安装文件。 建议最好下载 nodist,这样方便之后的node版本管理。
第二步 安装Git
上官网下载git即可。
第三步 hexo安装与使用
- 安装: 直接在桌面右键点击git bash here,输入以下命令:
npm install hexo -g
- 初始化配置: 创建文件夹(如 D:\self\myBlog),直接进入myBlog文件夹下右键点击git bash here:
hexo init
npm install
- 安装hexo插件,(保证之后有些操作不出错, 以下代码可以一起复制粘贴到命令窗):
npm install hexo-generator-index --save
npm install hexo-generator-archive --save
npm install hexo-generator-category --save
npm install hexo-generator-tag --save
npm install hexo-server --save
npm install hexo-deployer-git --save
npm install hexo-deployer-heroku --save
npm install hexo-deployer-rsync --save
npm install hexo-deployer-openshift --save
npm install hexo-renderer-marked@0.2 --save
npm install hexo-renderer-stylus@0.2 --save
npm install hexo-generator-feed@1 --save
npm install hexo-generator-sitemap@1 --save
- 本地查看效果:
hexo generate
hexo server
这样就可以在浏览器中访问localhost:4000
第四步 将博客部署到Github pages上
- 首先要有github账户。
- 创建新的repository,复制到你创建的repository的https链接。
- 在myBlog文件夹下打开_config.yml 在配置文件里修改:(记住:冒号后面一定要有空格!)
deploy:
type: git
repository: 你创建的repository的https链接
branch: 你的分支
- 在myBlog文件夹下执行:
hexo g -d
- 我是部署到master分支上,设置master分支为site分支,所以访问创建好的repository链接就能看到效果。 注明:如果你不能访问到css,js文件的话,说明路径不对,这时候可以修改_config.yml里面的root值,将root改成你的路径下。
第五步 添加主题美化博客
- 进入hexo.io/themes/,选择自…
- 在myBlog文件夹的themes目录下右键进入git命令框: 我选择的是hexo-theme-next 主题
git clone https://github.com/iissnan/hexo-theme-next(此处地址替换成你需要使用的主题的地址)
下载完之后。 3. 修改myBlog目录下的_config.yml文件里面的theme:hexo-theme-next 4. 部署到github上:
hexo clean
hexo g -d
- 打开自己的主页就能看到效果了。
第六步 配置分类与标签
- 在myBlog文件夹下执行:
hexo new page "categories" // 创建分类
hexo new page "tags" // 创建标签
- 打开/source/categories路径下的index.md,将其修改成:
---
title: catagories
date: 2017-06-11 19:40
type: "categories"
---
- 打开/source/tags路径下的index.md,将其修改成:
---
title: tags
date: 2017-06-11 19:40
type: "tags"
---
- 打开scaffolds/post.md文件,在tags:上面加一行categories:
- 创建新页面:
hexo n "fisrtPage"
可以看到source/_post文件夹下有firstPage.md就能设置categories属性为你想要分类的值,标签设置如果多个标签,设置如下:
tags: [tag1,tag2,...]
其他设置
- 设置中文 在_config.yml文件中找到language,设置为language: zh-Hans
- 主页显示分类与标签 找到所用主题文件夹(如themes的hexo-theme-next)里的_config.yml 找到menu配置处:
menu:
home: / || home
tags: /tags/ || tags
categories: /categories/ || th
archives: /archives/ || archive
- 首页不显示文章全文设置: 找到所用主题文件夹(如themes的hexo-theme-next)里的_config.yml
auto_excerpt:
enable: true
length: 150