环境配置
- 下载并安装node.js,https://nodejs.org/en/download/。 
- 下载并安装git,https://git-scm.com/downloads。 
- 安装cnpm,在命令行工具输入: - 1 - npm install -g cnpm --registry=https://registry.npm.taobao.org 
- 安装hexo,在命令行工具输入: - 1 - cnpm install -g hexo-cli 
本地搭建博客
- 在自己喜欢的地方新建一个空白文件夹,例如:“D:\BLOG”。 
- 在“D:\BLOG”路径下打开命令行工具(以下操作都基于此路径,以后不再重复提示),输入命令进行初始化,如果是windows系统: - 1 - hexo init - 如果是linux系统: - 1 - sudo hexo init 
- 打开hexo服务器:输入如下命令,访问 localhost:4000 可以看到默认主题(landscape)的个人主页。 - 1 - hexo s 
写博客
- 新建博客,输入命令: - 1 - hexo n "一篇博客" - 双引号内是博客的篇名,创建后可以在本地 D:\BLOG\source_posts 看到 一篇博客.md 文件生成,在此文件中进行博客创作并保存。推荐使用typora来编辑md文件。 
- 生成博客,输入命令: - 1 - hexo g 
- 打开hexo服务器:输入如下命令,访问 localhost:4000 可以看到自己的博客: - 1 - hexo s 
将博客部署到github
- 下载hexo-deployer-git,输入命令: - 1 - cnpm install --save hexo-deployer-git 
- 创建repo,注意repo命名则为后续访问博客的url。复制HTTPS。 
- 修改D:\BLOG\_config.yml文件: - 1 
 2
 3
 4
 5
 6- # Deployment 
 ## Docs: https://hexo.io/docs/deployment.html
 deploy:
 type:
 repo:
 branch:- 改为: - 1 
 2
 3
 4
 5
 6- # Deployment 
 ## Docs: https://hexo.io/docs/deployment.html
 deploy:
 type: git
 repo: #你刚复制的HTTPS:http:/github.com/用户名/repo名.git
 branch: master
- 清理和生成博客,输入命令: - 1 
 2- hexo clean 
 hexo g
- 部署到github,输入命令: - 1 - hexo d - 接下来就可以通过你的HTTPS来访问你的博客了。 - 之后如果博客变更,则可以执行: - 1 
 2
 3- hexo clean 
 hexo g
 hexo d
更换主题
- 找主题资源。可以通过https://hexo.io/themes自己找找主题;可以通过github找主题。 
- 将主题资源clone到D:\BLOG\themes\【主题名】。 - 此处用github上的一个主题项目来作例:https://github.com/theme-next/hexo-theme-next - 执行命令,next作为主题名: - 1 - git clone https://github.com/theme-next/hexo-theme-next themes/next 
- 修改D:\BLOG\_config.yml文件: - 1 
 2
 3
 4- # Extensions 
 ## Plugins: https://hexo.io/plugins/
 ## Themes: https://hexo.io/themes/
 theme: landscape- 改为: - 1 
 2
 3
 4- # Extensions 
 ## Plugins: https://hexo.io/plugins/
 ## Themes: https://hexo.io/themes/
 theme: next
- 输入命令更新并查看样式: - 1 
 2
 3- hexo clean 
 hexo g
 hexo s
其他
hexo-themes 主题推荐(个人)
- https://siricee.github.io/hexo-theme-Chic/
- https://probberechts.github.io/hexo-theme-cactus/cactus-dark/public/
- https://chengkang.me/hexo-theme-qna/
- 白色、简约、经典:https://theme-next.org/
- 暗色、简洁:https://lyndonoc.github.io/
- 白色、简洁、汉字:https://shiolife.cn/lagom/
- 古早、小黄人:http://blackshow.me/
文章折叠和“阅读全文”的设置
进阶设置
关于浏览量统计等杂七杂八:http://yearito.cn/posts/hexo-advanced-settings.html