把搭建本博客的过程和坑记录一下,方便以后维护。也可以用于搭建自己的博客。
注:想要搭建自己的博客的,请看详细版。简略版主要是用于快速搭建此博客,自己的博客还是全新搭建比较好。
简略版(快速搭建此itxia博客)
安装
- 安装 - Git、- node (npm)、- Hexo。
 以下命令仅作示例(Ubuntu 18.04):- 1 
 2
 3
 4
 5
 6
 7- sudo apt install git nodejs 
 Maybe you need to install 'npm' separately
 Strongly recommened in China:
 sudo npm config set registry https://registry.npm.taobao.org
 sudo npm install --unsafe-perm --verbose -g hexo-cli
 to verify installation
 hexo -v
- 克隆该博客仓库及hexo相关操作 - 1 
 2
 3
 4- git clone git@github.com:itxia/blog.git 
 cd blog/HEXO
 Ensure 'package.json' exists in this directory before doing the next
 npm install
用法
博客文章存放于/source/_post/里面。(如果是要写自己的博客,你可以删掉里面的.md文件。)
- 新建一篇文章。hexo new test。test是你的文章名字(不一定是标题),最好不要有空格。
- 编辑/source/_post/test.md文件,写你想写的。
- 生成文件。hexo generate,等待。
- 启动本地预览。hexo server,按提示在浏览器中打开http://localhost:4000即可。可以使用hexo server --debug,这样修改md文件并保存后可以热更新。
- 提交到GitHub。本地预览完毕,没有错误,可以提交。hexo deploy。
注:以上的几个hexo命令可以简写为首字母,如hexo n test、hexo g、hexo s --debug、hexo d。如果你对修改很有信心不要预览直接提交,可以hexo d -g。
详细版(用于一般性的搭建)
请查看简书文章1(总体搭建)、简书文章2(关于NexT主题),然后再看上面的简略版。
这里给出一个步骤:
- 安装 - 1 
 2
 3
 4
 5
 6
 7- sudo apt install git nodejs 
 Maybe you need to install 'npm' separately
 Strongly recommened in China:
 sudo npm config set registry https://registry.npm.taobao.org
 sudo npm install --unsafe-perm --verbose -g hexo-cli
 to verify installation
 hexo -v
- hexo初始化及安装必要的包 - 1 
 2
 3
 4- cd <your_blog_dir> 
 hexo init
 Ensure 'package.json' exists in this directory before doing the next
 npm install
- 搭建自己的博客,需要配置一下 - /_config.yml文件,从上往下依次包括- Site、- URL、- theme、- Deployment。应该不难理解,如果不懂可以看上述两篇文章。